docs: add note about default padding in crypto
[platform/upstream/nodejs.git] / benchmark / http_simple_bench.sh
1 #!/bin/bash
2
3 SERVER=127.0.0.1
4 PORT=${PORT:=8000}
5
6 # You may want to configure your TCP settings to make many ports available
7 # to node and ab. On macintosh use: 
8 #   sudo sysctl -w net.inet.ip.portrange.first=32768
9 #   sudo sysctl -w net.inet.tcp.msl=1000
10
11 if [ ! -d benchmark/ ]; then
12   echo "Run this script from the node root directory"
13   exit 1
14 fi
15
16 if [ $SERVER == "127.0.0.1" ]; then
17   ./iojs benchmark/http_simple.js &
18   node_pid=$!
19   sleep 1
20 fi
21
22 date=`date "+%Y%m%d%H%M%S"`
23
24 ab_hello_world() {
25   local type="$1"
26   local ressize="$2"
27   if [ $type == "string" ]; then 
28     local uri="bytes/$ressize"
29   else
30     local uri="buffer/$ressize"
31   fi
32
33
34   name="ab-hello-world-$type-$ressize"
35
36   dir=".benchmark_reports/$name/$rev/"
37   if [ ! -d $dir ]; then
38     mkdir -p $dir
39   fi
40
41   summary_fn="$dir/$date.summary"
42   data_fn="$dir/$date.data"
43
44   echo "Bench $name starts in 3 seconds..."
45   # let shit calm down
46   sleep 3
47
48   # hammer that as hard as it can for 10 seconds.
49   ab -g $data_fn -c 100 -t 10 http://$SERVER:$PORT/$uri > $summary_fn
50
51   # add our data about the server
52   echo >> $summary_fn
53   echo >> $summary_fn
54   echo "webserver-rev: $rev" >> $summary_fn
55   echo "webserver-uname: $uname" >> $summary_fn
56
57   grep Req $summary_fn 
58
59   echo "Summary: $summary_fn"
60   echo
61 }
62
63 # 1k
64 ab_hello_world 'string' '1024'
65 ab_hello_world 'buffer' '1024'
66
67 # 100k 
68 ab_hello_world 'string' '102400'
69 ab_hello_world 'buffer' '102400'
70
71
72 if [ ! -z $node_pid ]; then
73   kill -9 $node_pid
74 fi