Skip to content

Commit 7ee28ef

Browse files
Average over n runs
1 parent d02b151 commit 7ee28ef

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

.github/scripts/csv_to_md.py

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
1-
import sys
1+
import argparse
22
import csv
33
import tabulate as tab
44

5-
csv_benchmark = sys.argv[1]
6-
csv_baseline = sys.argv[2]
5+
parser = argparse.ArgumentParser()
6+
parser.add_argument('-b', '--baseline', required=True, help='Baseline CSV file')
7+
parser.add_argument('-c', '--current', required=True, help='Current CSV file')
8+
args = parser.parse_args()
79

8-
pretty = lambda x : "{:.1f}".format(x) if x <= 0 else "+{:.1f}".format(x)
10+
def get_2d_list(csv_filename):
11+
with open(csv_filename) as csv_file:
12+
csv_reader = csv.reader(csv_file)
13+
next(csv_reader)
14+
return [row for row in csv_reader]
915

10-
with open(csv_benchmark) as csv_file:
11-
csv_reader = csv.reader(csv_file)
12-
next(csv_reader)
13-
table_benchmark = [row for row in csv_reader]
14-
15-
with open(csv_baseline) as csv_file:
16-
csv_reader = csv.reader(csv_file)
17-
next(csv_reader)
18-
table_baseline = [row for row in csv_reader]
16+
table_baseline = get_2d_list(args.baseline)
17+
table_current = get_2d_list(args.current)
18+
19+
pretty = lambda x : f'{x:.1f}'
20+
21+
def get_emoji(difference, stdev):
22+
z = 1.96 # 95% confidence interval
23+
if difference < z * stdev:
24+
return ':green_circle:'
25+
elif difference > z * stdev:
26+
return ':red_circle:'
27+
else:
28+
return ':white_circle:'
1929

2030
table = []
21-
for benchmark, baseline in zip(table_benchmark, table_baseline):
22-
assert(benchmark[0] == baseline[0])
23-
name = benchmark[0]
24-
time = benchmark[1]
25-
stdev = u"\u00B1" + str(benchmark[2])
26-
d = float(baseline[1]) - float(benchmark[1])
27-
emoji = ':red_circle:' if 0 < d else ':green_circle:'
28-
difference = pretty(d)
29-
percent = pretty(100 * d / float(baseline[1]))
30-
table.append([name, time, stdev, emoji, difference, percent])
31+
for current, baseline in zip(table_current, table_baseline):
32+
assert(current[0] == baseline[0])
33+
name = current[0]
34+
time = int(float(current[1]))
35+
stdev = pretty(float(current[2]))
36+
d = float(baseline[1]) - float(current[1])
37+
difference = int(d)
38+
percent = pretty(0 if float(baseline[1]) == 0.0 else 100 * d / float(baseline[1]))
39+
emoji = get_emoji(d, float(current[2]))
40+
table.append([name, time, stdev, difference, percent, emoji])
3141

32-
header = ["name", "time", "stdev", "", "difference", "percent"]
42+
header = ["name", "time", "stdev", "difference", "percent", ""]
3343
print(tab.tabulate(table, header, tablefmt="github"))

.github/workflows/standalone-benchmark.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
name: ${{ matrix.name }}
4040
steps:
4141
- name: Checkout Repository
42-
uses: actions/checkout@v4
42+
uses: actions/checkout@v6
4343

4444
- name: Download Files
4545
run: |
@@ -87,19 +87,19 @@ jobs:
8787
source /etc/profile.d/modules.sh
8888
module load ninja/fortran-v1.11.1.g9-15 Vc/1.4.5-10 boost/v1.83.0-alice2-57 fmt/11.1.2-14 CMake/v3.31.6-10 ms_gsl/4.2.1-3 Clang/v20.1.7-9 TBB/v2022.3.0-3 ROOT/v6-36-04-alice9-15 ONNXRuntime/v1.22.0-71 GLFW/3.3.2-25
8989
cd ${STANDALONE_DIR}
90-
${STANDALONE_DIR}/ca -e 50kHz -g --memSize 15000000000 --sync --runs 42 --debug 1 --PROCtimingCSV ${BENCHMARK_CSV}
90+
${STANDALONE_DIR}/ca -e 50kHz -g --memSize 15000000000 --sync --runs 12 --debug 1 --PROCtimingCSV ${BENCHMARK_CSV}
9191
rm -rf ${STANDALONE_DIR}/events/50kHz ${STANDALONE_DIR}/build
9292
9393
- name: Display table on GitHub web
9494
run: |
9595
source /etc/profile.d/modules.sh
9696
module load ninja/fortran-v1.11.1.g9-15 Vc/1.4.5-10 boost/v1.83.0-alice2-57 fmt/11.1.2-14 CMake/v3.31.6-10 ms_gsl/4.2.1-3 Clang/v20.1.7-9 TBB/v2022.3.0-3 ROOT/v6-36-04-alice9-15 ONNXRuntime/v1.22.0-71 GLFW/3.3.2-25
9797
python3 ${GITHUB_WORKSPACE}/.github/scripts/merge_runs.py --discard 2 --input ${BENCHMARK_CSV} --output ${BENCHMARK_CSV}
98-
#python3 ${GITHUB_WORKSPACE}/.github/scripts/csv_to_md.py ${BENCHMARK_CSV} ${STANDALONE_DIR}/baseline/${{ matrix.name }}.csv >> ${GITHUB_STEP_SUMMARY}
98+
python3 ${GITHUB_WORKSPACE}/.github/scripts/csv_to_md.py --baseline ${STANDALONE_DIR}/baseline/${{ matrix.name }}.csv --current ${BENCHMARK_CSV} >> ${GITHUB_STEP_SUMMARY}
9999
rm -rf ${STANDALONE_DIR}/baseline
100100
101101
- name: Upload Artifact
102-
uses: actions/upload-artifact@v4
102+
uses: actions/upload-artifact@v6
103103
with:
104104
name: ${{ matrix.name }}-artifact
105105
path: /root/${{ matrix.name }}.csv

0 commit comments

Comments
 (0)