summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-01-24 17:23:11 -0800
committerisaacs <i@izs.me>2013-01-24 17:23:22 -0800
commit72dd3b4e2521b4913f0a44117e6b69d70786e43d (patch)
treea187067dfa36e02069788b3f1c6108d96b04df8b
parent34131af6067e6981d737bb8f58218d5d5e1b6484 (diff)
downloadnode-72dd3b4e2521b4913f0a44117e6b69d70786e43d.tar.gz
benchmark: Port http.sh from master
-rwxr-xr-xbenchmark/http.sh43
1 files changed, 37 insertions, 6 deletions
diff --git a/benchmark/http.sh b/benchmark/http.sh
index 40d0c714c..9a844a900 100755
--- a/benchmark/http.sh
+++ b/benchmark/http.sh
@@ -1,12 +1,43 @@
#!/bin/bash
cd "$(dirname "$(dirname $0)")"
-sudo sysctl -w net.inet.ip.portrange.first=12000
-sudo sysctl -w net.inet.tcp.msl=1000
-sudo sysctl -w kern.maxfiles=1000000 kern.maxfilesperproc=1000000
+
+if type sysctl &>/dev/null; then
+ # darwin and linux
+ sudo sysctl -w net.ipv4.ip_local_port_range="12000 65535"
+ sudo sysctl -w net.inet.ip.portrange.first=12000
+ sudo sysctl -w net.inet.tcp.msl=1000
+ sudo sysctl -w kern.maxfiles=1000000 kern.maxfilesperproc=1000000
+elif type /usr/sbin/ndd &>/dev/null; then
+ # sunos
+ /usr/sbin/ndd -set /dev/tcp tcp_smallest_anon_port 12000
+ /usr/sbin/ndd -set /dev/tcp tcp_largest_anon_port 65535
+ /usr/sbin/ndd -set /dev/tcp tcp_max_buf 2097152
+ /usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 1048576
+ /usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 1048576
+fi
+
ulimit -n 100000
-./node benchmark/http_simple.js || exit 1 &
+k=${KEEPALIVE}
+if [ "$k" = "no" ]; then
+ k=""
+else
+ k="-k"
+fi
+node=${NODE:-./node}
+
+$node benchmark/http_simple.js &
+npid=$!
+
sleep 1
-ab -n 30000 -c 100 http://127.0.0.1:8000/${TYPE:-bytes}/${LENGTH:-1024} | grep Req
-killall node
+if [ "$k" = "-k" ]; then
+ echo "using keepalive"
+fi
+
+for i in a a a a a a a a a a a a a a a a a a a a; do
+ ab $k -t 10 -c 100 http://127.0.0.1:8000/${TYPE:-bytes}/${LENGTH:-1024} \
+ 2>&1 | grep Req | egrep -o '[0-9\.]+'
+done
+
+kill $npid