-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark
executable file
·75 lines (64 loc) · 1.56 KB
/
benchmark
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
BENCHMARK_THREADS=1
BENCHMARK_DURATION=10
BENCHMARK_CONNECTIONS=1
RENDERER=( "erb-app" "liquid-app" "haml-app" "slim-app" )
ORMS=( "activerecord-app" "couchrest-app" "mongoid-app" "ohm-app" "sequel-app" )
function run_app() {
rackup > /dev/null 2>&1 &
}
function run_bench() {
wrk -t$BENCHMARK_THREADS -d$BENCHMARK_DURATION -c$BENCHMARK_CONNECTIONS http://localhost:9292/
}
function kill_process_by_id() {
kill -9 "$1"
}
function run_benchmark() {
name=("$@")
for app in "${name[@]}"
do
if [ "$app" == "${!#}" ]; then
echo "Finished benchmarking for $app"
exit 0;
fi
printf "Starting with %s\n" "$app"
cd "${!#}/$app" || exit
run_app
pid="$(echo $!)"
sleep 5 # let server start up
benchmark=$(run_bench)
printf "Finished profiling %s\n" "$app"
printf "Results:\n"
printf "%s\n" "$benchmark"
kill_process_by_id "$pid"
echo "Killing process"
cd ../..
done
}
function run_benchmarks() {
echo "Start profiling for $1"
if [ "$1" == 'renderer' ]; then
run_benchmark "${RENDERER[@]}" renderer
elif [ "$1" == 'orms' ]; then
run_benchmark "${ORMS[@]}" orms
else
echo "Something went wrong"
fi
}
if [ -z "$1" ]; then
echo "Please provide an input parameter (renderer, orms)"
exit 1;
fi
if [ "$1" == 'renderer' ]; then
run_benchmarks "$1"
exit 0;
elif [ "$1" == 'orms' ]; then
run_benchmarks "$1"
exit 0;
elif [ "$1" == 'renderer' ]; then
echo "Start profiling for $1"
exit 0;
else
echo "Please provide a valid input parameter (renderer, orms)"
exit 1;
fi