2 cd "$(dirname "$(dirname $0)")"
8 if type sysctl &>/dev/null; then
10 sudo sysctl -w net.inet.ip.portrange.first=12000
11 sudo sysctl -w net.inet.tcp.msl=1000
12 sudo sysctl -w kern.maxfiles=1000000 kern.maxfilesperproc=1000000
13 elif type /usr/sbin/ndd &>/dev/null; then
15 /usr/sbin/ndd -set /dev/tcp tcp_smallest_anon_port 12000
16 /usr/sbin/ndd -set /dev/tcp tcp_largest_anon_port 65535
17 /usr/sbin/ndd -set /dev/tcp tcp_max_buf 2097152
18 /usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 1048576
19 /usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 1048576
23 $node benchmark/http_simple.js &
25 echo "node pid = $nodepid"
28 # has to stay alive until dtrace exits
29 dtrace -n 'profile-97/pid == '$nodepid' && arg1/{ @[jstack(150, 8000)] = count(); } tick-60s { exit(0); }' \
30 | grep -v _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinA \
35 echo "dtrace pid = $dtracepid"
44 ab $k -t 10 -c $c http://127.0.0.1:8000/$t/$l \
50 #test 100 bytes 1024 -k
51 #test 100 bytes 1024 -k
52 #test 100 bytes 1024 -k
54 echo 'Keep going until dtrace stops listening...'
55 while pargs $dtracepid &>/dev/null; do
56 test 100 bytes ${LENGTH:-1} -k
61 echo 'Turn the stacks into a svg'
62 stackvis dtrace flamegraph-svg < "$name".src > "$name".raw.svg
64 echo 'Prune tiny stacks out of the graph'
66 var infile = process.argv[1];
67 var outfile = process.argv[2];
69 var fs = require("fs");
70 var input = fs.readFileSync(infile, "utf8");
72 input = input.split("id=\"details\" > </text>");
73 var head = input.shift() + "id=\"details\" > </text>";
74 input = input.join("id=\"details\" > </text>");
77 input = input.split("</svg>")[0];
79 var minyKept = Infinity;
80 var minyOverall = Infinity;
81 var rects = input.trim().split(/\n/).filter(function(rect) {
82 var my = rect.match(/y="([0-9\.]+)"/);
89 minyOverall = Math.min(minyOverall, y);
91 // pluck off everything that will be less than one pixel.
92 var mw = rect.match(/width="([0-9\.]+)"/)
98 minyKept = Math.min(minyKept, y);
102 // move everything up to the top of the page.
103 var ydiff = minyKept - minyOverall;
104 rects = rects.map(function(rect) {
105 var my = rect.match(/y="([0-9\.]+)"/);
107 var newy = y - ydiff;
108 rect = rect.replace(/y="([0-9\.]+)"/, "y=\"" + newy + "\"");
112 fs.writeFileSync(outfile, head + "\n" + rects.join("\n") + "\n" + tail);
113 ' "$name".raw.svg "$name".svg
116 echo 'done. Results in '"$name"'.svg'