From 616c36fb2409a7d44c1715b2b1d11e03dc49a2dc Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Sat, 20 Mar 2021 11:02:29 -0700 Subject: [PATCH] test: Add benchmark.sh script for collecting benchmark data --- test/benchmark-fast.json | 5 ++++ test/benchmark.json | 5 ++++ test/benchmark.sh | 63 ++++++++++++++++++++++++++++++++++++++++ test/verify-fast.json | 11 +++++++ test/verify.json | 9 ++++++ 5 files changed, 93 insertions(+) create mode 100644 test/benchmark-fast.json create mode 100644 test/benchmark.json create mode 100755 test/benchmark.sh create mode 100644 test/verify-fast.json create mode 100644 test/verify.json diff --git a/test/benchmark-fast.json b/test/benchmark-fast.json new file mode 100644 index 00000000..ed983865 --- /dev/null +++ b/test/benchmark-fast.json @@ -0,0 +1,5 @@ +{ 'commands' : [ + { 'add_country' : { 'name' : 'faroe_islands' }}, + { 'start_bygfoot' : { }}, + { 'simulate_games' : {'weeks' : 48 }}, +]} diff --git a/test/benchmark.json b/test/benchmark.json new file mode 100644 index 00000000..7846b9aa --- /dev/null +++ b/test/benchmark.json @@ -0,0 +1,5 @@ +{ 'commands' : [ + { 'add_country' : { 'name' : 'england' }}, + { 'start_bygfoot' : { }}, + { 'simulate_games' : {'weeks' : 48 }}, +]} diff --git a/test/benchmark.sh b/test/benchmark.sh new file mode 100755 index 00000000..727692fe --- /dev/null +++ b/test/benchmark.sh @@ -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 diff --git a/test/verify-fast.json b/test/verify-fast.json new file mode 100644 index 00000000..44599d49 --- /dev/null +++ b/test/verify-fast.json @@ -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' : { }}, +]} + diff --git a/test/verify.json b/test/verify.json new file mode 100644 index 00000000..6356ec76 --- /dev/null +++ b/test/verify.json @@ -0,0 +1,9 @@ +{ 'commands' : [ + { 'add_country' : { 'name' : 'england' }}, + { 'start_bygfoot' : { }}, + { 'simulate_games' : {'weeks' : 48 }}, + { 'dump_bygfoot' : { }}, + { 'simulate_games' : {'seasons' : 1 }}, + { 'dump_bygfoot' : { }}, +]} +