File: http.sh

package info (click to toggle)
nodejs 4.8.2~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 62,476 kB
  • ctags: 111,183
  • sloc: cpp: 661,544; ansic: 31,406; python: 23,073; makefile: 1,418; sh: 1,384; perl: 255; lisp: 222; ruby: 76; xml: 50
file content (43 lines) | stat: -rwxr-xr-x 1,043 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
cd "$(dirname "$(dirname $0)")"

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

k=${KEEPALIVE}
if [ "$k" = "no" ]; then
  k=""
else
  k="-k"
fi
node=${NODE:-./node}

$node benchmark/http_simple.js &
npid=$!

sleep 1

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