Skip to content

Commit

Permalink
test: Add benchmark.sh script for collecting benchmark data
Browse files Browse the repository at this point in the history
  • Loading branch information
tstellar committed Mar 27, 2021
1 parent 8a701be commit 0683086
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/benchmark-fast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'faroe_islands' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
]}
5 changes: 5 additions & 0 deletions test/benchmark.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'england' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
]}
63 changes: 63 additions & 0 deletions test/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

set -e

output_dir=`pwd`

while [ $# -gt 0 ]; do
case $1 in
--all)
verify=1
benchmark=1
profile=1
;;
--verify)
verify=1
;;
--benchmark)
benchmark=1
;;
--profile)
profile=1
;;
--output-dir)
shift
output_dir=$1
;;
--fast)
input_suffix="-fast"
;;
*)
bygfoot_bin=$1
;;
esac
shift
done

if [ -z "$verify$profile" ]; then
benchmark=1
fi

mkdir -p $output_dir
bygfoot_bindir=`dirname $bygfoot_bin`
input_dir=`pwd`/`dirname "$0"`

pushd $bygfoot_bindir

tmphome=`mktemp -d`
export HOME=$tmphome

set -x

if [ -n "$verify" ]; then
./bygfoot --random-seed=1 --json=$input_dir/verify$input_suffix.json &> $output_dir/verify.log
gzip $output_dir/verify.log
fi

if [ -n "$benchmark" ]; then
perf stat -B ./bygfoot --random-seed=1 --json=$input_dir/benchmark$input_suffix.json &> $output_dir/benchmark.log
fi

if [ -n "$profile" ]; then
perf record -g -o $output_dir/perf.data ./bygfoot --random-seed=1 --json=$input_dir/benchmark$input_suffix.json
fi
11 changes: 11 additions & 0 deletions test/verify-fast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'faroe_islands' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
{ 'dump_bygfoot' : { }},
{ 'simulate_games' : {'seasons' : 1 }},
{ 'dump_bygfoot' : { }},
{ 'simulate_games' : {'seasons' : 1 }},
{ 'dump_bygfoot' : { }},
]}

9 changes: 9 additions & 0 deletions test/verify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'england' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
{ 'dump_bygfoot' : { }},
{ 'simulate_games' : {'seasons' : 1 }},
{ 'dump_bygfoot' : { }},
]}

0 comments on commit 0683086

Please sign in to comment.