Skip to content

Commit

Permalink
feat: output wrk results to a csv (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung authored and fengmk2 committed Apr 12, 2017
1 parent 9a18a12 commit 63d315a
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ run/
.DS_Store
*.swp
/wrk
stats.csv
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"test-simple": "simple/run.sh",
"test-simple-view": "simple_view/run.sh",
"test-simple-passport": "simple_passport/run.sh",
"test": "npm run test-simple && npm run test-simple-view && npm run test-simple-passport",
"test": "cat stats-header.csv > stats.csv && npm run test-simple && npm run test-simple-view && npm run test-simple-passport",
"ci": "./install-wrk.sh && npm test",
"autod": "autod"
},
Expand Down
14 changes: 14 additions & 0 deletions report.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
done = function(summary, latency, requests)
filename = "stats.csv"
statsfile = assert(io.open(filename, "a"))
statsfile.write(statsfile, string.format("%.2f,", latency.min));
statsfile.write(statsfile, string.format("%.2f,", latency.max));
statsfile.write(statsfile, string.format("%.2f,", latency.mean));
statsfile.write(statsfile, string.format("%.2f,", latency.stdev));
statsfile.write(statsfile, string.format("%d,", summary.duration));
statsfile.write(statsfile, string.format("%d,", summary.requests));
statsfile.write(statsfile, string.format("%d,", summary.bytes));
statsfile.write(statsfile, string.format("%.2f,", summary.requests / summary.duration * 1e6));
statsfile.write(statsfile, string.format("%.2f\n", summary.bytes / summary.duration * 1e6));
statsfile.close()
end
20 changes: 16 additions & 4 deletions simple/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

export PATH=`dirname $0`/../wrk:$PATH
CSV=`dirname $0`/../stats.csv
REPORT=`dirname $0`/../report.lua

echo
EGG_SERVER_ENV=prod node $NODE_FLAGS `dirname $0`/dispatch.js $1 &
Expand All @@ -12,39 +14,49 @@ curl 'http://127.0.0.1:7003/'
curl 'http://127.0.0.1:7001/'
curl 'http://127.0.0.1:7001/aa'

test `tail -c 1 $CSV` && printf "\n" >> $CSV

echo ""
echo "------- koa hello -------"
echo ""
printf "\"koa hello\"," >> $CSV
wrk 'http://127.0.0.1:7002/' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- toa hello -------"
echo ""
printf "\"toa hello\"," >> $CSV
wrk 'http://127.0.0.1:7003/' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg hello -------"
echo ""
printf "\"egg hello\"," >> $CSV
wrk 'http://127.0.0.1:7001/' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg hello (Async Await) -------"
echo ""
printf "\"egg hello (Async Await)\"," >> $CSV
wrk 'http://127.0.0.1:7001/aa' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

kill $pid
12 changes: 10 additions & 2 deletions simple_passport/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

export PATH=`dirname $0`/../wrk:$PATH
CSV=`dirname $0`/../stats.csv
REPORT=`dirname $0`/../report.lua

echo
EGG_SERVER_ENV=prod node $NODE_FLAGS `dirname $0`/dispatch.js $1 &
Expand All @@ -10,22 +12,28 @@ sleep 6
curl 'http://127.0.0.1:7001/'
curl 'http://127.0.0.1:7001/aa'

test `tail -c 1 $CSV` && printf "\n" >> $CSV

sleep 3
echo ""
echo "------- egg passport -------"
echo ""
printf "\"egg passport\"," >> $CSV
wrk 'http://127.0.0.1:7001/' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg passport (Async Await) -------"
echo ""
printf "\"egg passport (Async Await)\"," >> $CSV
wrk 'http://127.0.0.1:7001/aa' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

kill $pid
28 changes: 22 additions & 6 deletions simple_view/run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

export PATH=`dirname $0`/../wrk:$PATH
CSV=`dirname $0`/../stats.csv
REPORT=`dirname $0`/../report.lua

echo
EGG_SERVER_ENV=prod node $NODE_FLAGS `dirname $0`/dispatch.js $1 &
Expand All @@ -14,57 +16,71 @@ curl 'http://127.0.0.1:7001/ejs' -s | grep 'title'
curl 'http://127.0.0.1:7001/nunjucks-aa' -s | grep 'title'
curl 'http://127.0.0.1:7001/ejs-aa' -s | grep 'title'

test `tail -c 1 $CSV` && printf "\n" >> $CSV

echo ""
echo "------- koa view -------"
echo ""
printf "\"koa view\"," >> $CSV
wrk 'http://127.0.0.1:7002/' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- toa view -------"
echo ""
printf "\"toa view\"," >> $CSV
wrk 'http://127.0.0.1:7003/' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg nunjucks view -------"
echo ""
printf "\"egg nunjucks view\"," >> $CSV
wrk 'http://127.0.0.1:7001/nunjucks' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg ejs view -------"
echo ""
printf "\"egg ejs view\"," >> $CSV
wrk 'http://127.0.0.1:7001/ejs' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg nunjucks view (Async Await) -------"
echo ""
printf "\"egg nunjucks view (Async Await)\"," >> $CSV
wrk 'http://127.0.0.1:7001/nunjucks-aa' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

sleep 3
echo ""
echo "------- egg ejs view (Async Await) -------"
echo ""
printf "\"egg ejs view (Async Await)\"," >> $CSV
wrk 'http://127.0.0.1:7001/ejs-aa' \
-d 10 \
-c 50 \
-t 8
-t 8 \
-s $REPORT

kill $pid
1 change: 1 addition & 0 deletions stats-header.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name,latency_min,latency_max,latency_mean,latency_stdev,duration,requests,bytes,req_per_sec,byte_per_sec

0 comments on commit 63d315a

Please sign in to comment.