Skip to content

Commit

Permalink
Merge pull request LesnyRumcajs#89 from brunoborges/analyzer
Browse files Browse the repository at this point in the history
Add 90/95/99% to report
  • Loading branch information
LesnyRumcajs authored Aug 12, 2020
2 parents a324106 + 97c36ef commit 19a7e14
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
9 changes: 9 additions & 0 deletions analyze.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
RESULTS_DIR=${RESULTS_DIR:-"${@}"}
echo "-----"
echo "Benchmark finished. Detailed results are located in: ${RESULTS_DIR}"
docker run --name analyzer --rm \
-v "${PWD}/analyze:/analyze:ro" \
-v "${PWD}/${RESULTS_DIR}:/reports:ro" \
ruby:2.7-buster ruby /analyze/results_analyze.rb reports ||
exit 1
17 changes: 13 additions & 4 deletions analyze/results_analyze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
0
end
results[name][:avg_resp_time] = File.read(file).scan(/\s*Average:\s*(.*\w)/)[0][0]
results[name][:_90pct] = File.read(file).scan(/\s*90 % in \s*(.*\w)/)[0][0]
results[name][:_95pct] = File.read(file).scan(/\s*95 % in \s*(.*\w)/)[0][0]
results[name][:_99pct] = File.read(file).scan(/\s*99 % in \s*(.*\w)/)[0][0]
results[name][:req_per_s] = results[name][:ok_responses] / results[name][:total_time]
end

Expand All @@ -45,21 +48,27 @@
end
end

make_horizontal_line = -> { puts '-' * 76 }
make_horizontal_line = -> { puts '-' * 128 }
make_data_line = lambda do |*args|
puts "| #{args[0].to_s.ljust(18)} |" \
"#{args[1].to_s.rjust(8)} |" \
"#{args[2].to_s.rjust(15)} |" \
"#{args[3].to_s.rjust(9)} |" \
"#{args[4].to_s.rjust(14)} |"
"#{args[3].to_s.rjust(15)} |" \
"#{args[3].to_s.rjust(15)} |" \
"#{args[4].to_s.rjust(15)} |" \
"#{args[5].to_s.rjust(9)} |" \
"#{args[6].to_s.rjust(14)} |"
end
make_horizontal_line[]
make_data_line['name', 'req/s', 'avg. latency', 'avg. cpu', 'avg. memory']
make_data_line['name', 'req/s', 'avg. latency', '90 % in', '95 % in', '99 % in', 'avg. cpu', 'avg. memory']
make_horizontal_line[]
results.sort_by { |_k, v| v[:req_per_s] }.reverse_each do |name, result|
make_data_line[name,
result[:req_per_s].round(0),
result[:avg_resp_time],
result[:_90pct],
result[:_95pct],
result[:_99pct],
result[:avg_cpu].round(2).to_s + '%',
result[:avg_mem].round(2).to_s + ' ' + result[:avg_mem_unit]]
end
Expand Down
8 changes: 1 addition & 7 deletions bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ for benchmark in ${BENCHMARKS_TO_RUN}; do
docker container stop "${NAME}" >/dev/null
done

echo "-----"
echo "Benchmark finished. Detailed results are located in: ${RESULTS_DIR}"
docker run --name analyzer --rm \
-v "${PWD}/analyze:/analyze:ro" \
-v "${PWD}/${RESULTS_DIR}:/reports:ro" \
ruby:2.7-buster ruby /analyze/results_analyze.rb reports ||
exit 1
sh analyze.sh $RESULTS_DIR

echo "All done."

0 comments on commit 19a7e14

Please sign in to comment.