[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [flashproxy/master] Let switching experiments write time to a log file.
commit c907b00a096f770942fc2df7507dcf54233a2659
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date: Mon Oct 31 01:26:12 2011 -0700
Let switching experiments write time to a log file.
---
experiments/common.sh | 10 ++++++++++
experiments/switching/local-http-alternating.sh | 13 ++++++++++---
experiments/switching/local-http-constant.sh | 12 +++++++++---
experiments/switching/remote-tor-alternating.sh | 12 +++++++++---
experiments/switching/remote-tor-constant.sh | 10 ++++++++--
5 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/experiments/common.sh b/experiments/common.sh
index 632a99b..f788235 100644
--- a/experiments/common.sh
+++ b/experiments/common.sh
@@ -35,3 +35,13 @@ browser_goto() {
ensure_browser_started "$PROFILE"
"$FIREFOX" -P "$PROFILE" -remote "openurl($URL)" 2>/dev/null
}
+
+# Run a command and get the "real" part of time(1) output as a number of
+# seconds.
+real_time() {
+ # Make a spare copy of stderr (fd 1).
+ exec 3>&2
+ # Point the subcommand's stderr to our copy (fd 3), and extract the
+ # original stderr (fd 2) output of time.
+ (time -p eval "$@" 2>&3) |& tail -n 3 | head -n 1 | awk '{print $2}'
+}
diff --git a/experiments/switching/local-http-alternating.sh b/experiments/switching/local-http-alternating.sh
index 5eea428..8e11065 100755
--- a/experiments/switching/local-http-alternating.sh
+++ b/experiments/switching/local-http-alternating.sh
@@ -1,8 +1,9 @@
#!/bin/bash
-# Usage: ./local-http-alternating.sh
+# Usage: ./local-http-alternating.sh [OUTPUT_FILENAME]
#
-# Tests a download over alternating flash proxies.
+# Tests a download over alternating flash proxies. If OUTPUT_FILENAME is
+# supplied, appends the time measurement to that file.
. ../common.sh
@@ -10,6 +11,7 @@ PROFILE_1=flashexp1
PROFILE_2=flashexp2
PROXY_URL="http://127.0.0.1:8000/swfcat.swf?facilitator=127.0.0.1:9002"
DATA_FILE_NAME="$FLASHPROXY_DIR/dump"
+OUTPUT_FILENAME="$1"
# Declare an array.
declare -a PIDS_TO_KILL
@@ -56,4 +58,9 @@ echo "Start socat."
PIDS_TO_KILL+=($!)
visible_sleep 1
-time wget http://127.0.0.1:2000/dump -t 0 -O /dev/null
+
+if [ -n "$OUTPUT_FILENAME" ]; then
+ real_time wget http://127.0.0.1:2000/dump -t 0 -O /dev/null >> "$OUTPUT_FILENAME"
+else
+ real_time wget http://127.0.0.1:2000/dump -t 0 -O /dev/null
+fi
diff --git a/experiments/switching/local-http-constant.sh b/experiments/switching/local-http-constant.sh
index 1a74aaf..0fed6e4 100755
--- a/experiments/switching/local-http-constant.sh
+++ b/experiments/switching/local-http-constant.sh
@@ -1,8 +1,9 @@
#!/bin/bash
-# Usage: ./local-http-constant.sh
+# Usage: ./local-http-constant.sh [OUTPUT_FILENAME]
#
-# Tests a download over an uninterrupted flash proxy.
+# Tests a download over an uninterrupted flash proxy. If OUTPUT_FILENAME
+# is supplied, appends the time measurement to that file.
. ../common.sh
@@ -10,6 +11,7 @@ PROFILE_1=flashexp1
PROFILE_2=flashexp2
PROXY_URL="http://127.0.0.1:8000/swfcat.swf?facilitator=127.0.0.1:9002"
DATA_FILE_NAME="$FLASHPROXY_DIR/dump"
+OUTPUT_FILENAME="$1"
# Declare an array.
declare -a PIDS_TO_KILL
@@ -51,4 +53,8 @@ echo "Start socat."
PIDS_TO_KILL+=($!)
visible_sleep 1
-time wget http://127.0.0.1:2000/dump -t 0 -O /dev/null
+if [ -n "$OUTPUT_FILENAME" ]; then
+ real_time wget http://127.0.0.1:2000/dump -t 0 -O /dev/null >> "$OUTPUT_FILENAME"
+else
+ real_time wget http://127.0.0.1:2000/dump -t 0 -O /dev/null
+fi
diff --git a/experiments/switching/remote-tor-alternating.sh b/experiments/switching/remote-tor-alternating.sh
index 52da3aa..5309dce 100755
--- a/experiments/switching/remote-tor-alternating.sh
+++ b/experiments/switching/remote-tor-alternating.sh
@@ -1,8 +1,9 @@
#!/bin/bash
-# Usage: ./remote-tor-alternating.sh
+# Usage: ./remote-tor-alternating.sh [OUTPUT_FILENAME]
#
-# Tests a Tor download over alternating flash proxies.
+# Tests a Tor download over alternating flash proxies. If OUTPUT_FILENAME is
+# supplied, appends the time measurement to that file.
. ../common.sh
@@ -10,6 +11,7 @@ PROFILE_1=flashexp1
PROFILE_2=flashexp2
PROXY_URL="http://127.0.0.1:8000/swfcat.swf?facilitator=127.0.0.1:9002"
DATA_FILE_NAME="$FLASHPROXY_DIR/dump"
+OUTPUT_FILENAME="$1"
# Declare an array.
declare -a PIDS_TO_KILL
@@ -52,4 +54,8 @@ PIDS_TO_KILL+=($!)
# Let Tor bootstrap.
visible_sleep 15
-time torify wget http://torperf.torproject.org/.5mbfile -t 0 -O /dev/null
+if [ -n "$OUTPUT_FILENAME" ]; then
+ real_time torify wget http://torperf.torproject.org/.5mbfile -t 0 -O /dev/null >> "$OUTPUT_FILENAME"
+else
+ real_time torify wget http://torperf.torproject.org/.5mbfile -t 0 -O /dev/null
+fi
diff --git a/experiments/switching/remote-tor-constant.sh b/experiments/switching/remote-tor-constant.sh
index 4f530be..c0d6338 100755
--- a/experiments/switching/remote-tor-constant.sh
+++ b/experiments/switching/remote-tor-constant.sh
@@ -2,7 +2,8 @@
# Usage: ./remote-tor-constant.sh
#
-# Tests a Tor download over an uninterrupted flash proxy.
+# Tests a Tor download over an uninterrupted flash proxy. If OUTPUT_FILENAME is
+# supplied, appends the time measurement to that file.
. ../common.sh
@@ -10,6 +11,7 @@ PROFILE_1=flashexp1
PROFILE_2=flashexp2
PROXY_URL="http://127.0.0.1:8000/swfcat.swf?facilitator=127.0.0.1:9002"
DATA_FILE_NAME="$FLASHPROXY_DIR/dump"
+OUTPUT_FILENAME="$1"
# Declare an array.
declare -a PIDS_TO_KILL
@@ -47,4 +49,8 @@ browser_goto "$PROFILE_1" "$PROXY_URL"
# Let Tor bootstrap.
visible_sleep 15
-time torify wget http://torperf.torproject.org/.5mbfile -t 0 -O /dev/null
+if [ -n "$OUTPUT_FILENAME" ]; then
+ real_time torify wget http://torperf.torproject.org/.5mbfile -t 0 -O /dev/null >> "$OUTPUT_FILENAME"
+else
+ real_time torify wget http://torperf.torproject.org/.5mbfile -t 0 -O /dev/null
+fi
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits