From 59c4e3569184b3c877462e73ff54f6e0880fa5aa Mon Sep 17 00:00:00 2001 From: visionmedia Date: Thu, 22 Apr 2010 12:04:28 -0700 Subject: [PATCH] Added graphing capabilities (gnuplot must be installed) --- .gitignore | 4 ++- Makefile | 6 +++- benchmarks/graph | 35 +++++++++++++++++++ benchmarks/run | 7 ++-- benchmarks/thin/simple.ru | 8 ++--- benchmarks/thin/simple.sinatra.ru | 9 ----- ...tatic.sinatra.large.ru => static.large.ru} | 0 .../thin/{static.sinatra.ru => static.ru} | 0 8 files changed, 50 insertions(+), 19 deletions(-) create mode 100755 benchmarks/graph delete mode 100644 benchmarks/thin/simple.sinatra.ru rename benchmarks/thin/{static.sinatra.large.ru => static.large.ru} (100%) rename benchmarks/thin/{static.sinatra.ru => static.ru} (100%) diff --git a/.gitignore b/.gitignore index 033ac25b..76ef5766 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ *.seed *.log *.csv -*.out \ No newline at end of file +*.plot +*.out +benchmarks/graphs \ No newline at end of file diff --git a/Makefile b/Makefile index fcedd347..7460b4f9 100644 --- a/Makefile +++ b/Makefile @@ -35,5 +35,9 @@ compile-coffee: benchmark: benchmarks/run @./benchmarks/run + @./benchmarks/graph -.PHONY: install test app \ No newline at end of file +graphs: + @./benchmarks/graph + +.PHONY: install test app benchmark graphs \ No newline at end of file diff --git a/benchmarks/graph b/benchmarks/graph new file mode 100755 index 00000000..e7d907f0 --- /dev/null +++ b/benchmarks/graph @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +# +# Output gnuplot script. +# +# <node> <express> <sinatra> +# + +function plot() { + cat <<-EOF +set terminal png +set output "benchmarks/graphs/$1.png" +set title "$1" +set size 1,0.7 +set grid y +set key left top +set xlabel "request percentage" +set xlabel "response time (ms)" +plot "benchmarks/$2" using 10 with lines title "node", \\ + "benchmarks/$3" using 10 with lines title "express", \\ + "benchmarks/$4" using 10 with lines title "sinatra thin" +EOF +} + +mkdir -p benchmarks/graphs + +for type in simple static static.large; do + echo ... generating benchmarks/graphs/$type.png + plot $type \ + express/$type.js.plot \ + node/$type.js.plot \ + thin/$type.ru.plot \ + > benchmarks/graphs/$type.p + gnuplot benchmarks/graphs/$type.p +done \ No newline at end of file diff --git a/benchmarks/run b/benchmarks/run index 5a785cb1..b2538a82 100755 --- a/benchmarks/run +++ b/benchmarks/run @@ -40,7 +40,7 @@ bm(){ esac pid=$! sleep $SLEEP - $AB $ABFLAGS -e benchmarks/$type/$file.csv $ADDR > benchmarks/$type/$file.out + $AB $ABFLAGS -g benchmarks/$type/$file.plot $ADDR > benchmarks/$type/$file.out log $(cat benchmarks/$type/$file.out | grep Requests) kill -KILL $pid } @@ -53,6 +53,5 @@ bm express simple.js bm express static.js bm express static.large.js bm thin simple.ru -bm thin simple.sinatra.ru -bm thin static.sinatra.ru -bm thin static.sinatra.large.ru \ No newline at end of file +bm thin static.ru +bm thin static.large.ru \ No newline at end of file diff --git a/benchmarks/thin/simple.ru b/benchmarks/thin/simple.ru index e359840a..f5d35344 100644 --- a/benchmarks/thin/simple.ru +++ b/benchmarks/thin/simple.ru @@ -1,9 +1,9 @@ require 'rubygems' -require 'rack' +require 'sinatra' -app = lambda do |env| - [200, { 'Content-Type' => 'text/plain' }, 'Hello World'] +get '/' do + 'Hello World' end -run app \ No newline at end of file +run Sinatra::Application \ No newline at end of file diff --git a/benchmarks/thin/simple.sinatra.ru b/benchmarks/thin/simple.sinatra.ru deleted file mode 100644 index f5d35344..00000000 --- a/benchmarks/thin/simple.sinatra.ru +++ /dev/null @@ -1,9 +0,0 @@ - -require 'rubygems' -require 'sinatra' - -get '/' do - 'Hello World' -end - -run Sinatra::Application \ No newline at end of file diff --git a/benchmarks/thin/static.sinatra.large.ru b/benchmarks/thin/static.large.ru similarity index 100% rename from benchmarks/thin/static.sinatra.large.ru rename to benchmarks/thin/static.large.ru diff --git a/benchmarks/thin/static.sinatra.ru b/benchmarks/thin/static.ru similarity index 100% rename from benchmarks/thin/static.sinatra.ru rename to benchmarks/thin/static.ru