test: Add benchmark.sh script for collecting benchmark data

This commit is contained in:
Tom Stellard 2021-03-20 11:02:29 -07:00 committed by Tom Stellard
parent 8a701be6a1
commit 068308636e
5 changed files with 93 additions and 0 deletions

5
test/benchmark-fast.json Normal file
View File

@ -0,0 +1,5 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'faroe_islands' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
]}

5
test/benchmark.json Normal file
View File

@ -0,0 +1,5 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'england' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
]}

63
test/benchmark.sh Executable file
View File

@ -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
test/verify-fast.json Normal file
View File

@ -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
test/verify.json Normal file
View File

@ -0,0 +1,9 @@
{ 'commands' : [
{ 'add_country' : { 'name' : 'england' }},
{ 'start_bygfoot' : { }},
{ 'simulate_games' : {'weeks' : 48 }},
{ 'dump_bygfoot' : { }},
{ 'simulate_games' : {'seasons' : 1 }},
{ 'dump_bygfoot' : { }},
]}