Skip to content

Commit c2f2f0e

Browse files
authored
Merge pull request #134 from AndreasGocht/master
Further update benchmarks and comparison.
2 parents 8206766 + 16ff348 commit c2f2f0e

5 files changed

Lines changed: 36 additions & 39 deletions

File tree

benchmark/bm_baseline.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
result = 0
44
iterations = int(sys.argv[1])
5-
iteration_list = list(range(iterations))
65

7-
for i in iteration_list:
6+
for i in range(iterations):
87
result += 1
98

109
assert(result == iterations)

benchmark/bm_simplefunc.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
'''
2-
Created on 04.10.2019
3-
4-
@author: gocht
5-
'''
61
import sys
72

83

@@ -12,9 +7,8 @@ def add(val):
127

138
result = 0
149
iterations = int(sys.argv[1])
15-
iteration_list = list(range(iterations))
1610

17-
for i in iteration_list:
11+
for i in range(iterations):
1812
result = add(result)
1913

2014
assert(result == iterations)

benchmark/compare.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
import pickle
33
import numpy
4-
from scipy.stats import linregress
54

65
parser = argparse.ArgumentParser(description='Compare two benchmarks.',
76
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
@@ -17,52 +16,52 @@
1716
with open(args.right, "rb") as f:
1817
right = pickle.load(f)
1918

20-
if left.keys()!=right.keys():
19+
if left.keys() != right.keys():
2120
raise ValueError("Different Experiments")
2221

2322
experiment = right.keys()
2423

2524
for exp in experiment:
2625
print("\nExperiment: {}".format(exp))
27-
if left[exp].keys()!=right[exp].keys():
26+
if left[exp].keys() != right[exp].keys():
2827
raise ValueError("Different Instrumenters")
2928
instrumenters = left[exp].keys()
30-
29+
3130
for inst in instrumenters:
3231
print("\n\tInstrumenter: {}".format(inst))
33-
if left[exp][inst].keys()!=right[exp][inst].keys():
32+
if left[exp][inst].keys() != right[exp][inst].keys():
3433
raise ValueError("Different Iterations")
3534
iterations = left[exp][inst].keys()
3635
Y_left = []
37-
Y_right = []
36+
Y_right = []
3837
X = []
3938
for it in iterations:
4039
left_val = left[exp][inst][it]
4140
right_val = right[exp][inst][it]
42-
if len(left_val)!=len(right_val):
41+
if len(left_val) != len(right_val):
4342
raise ValueError("Different Repetitons")
4443

45-
Y_left.append(left_val)
46-
Y_right.append(right_val)
47-
X.append(numpy.full([len(left_val)], it))
44+
Y_left.append(numpy.mean(left_val))
45+
Y_right.append(numpy.mean(right_val))
46+
X.append(numpy.full([1], it))
4847

4948
if args.s:
5049
print("\t\tInterations {}".format(it))
5150
print("\t\tMean: {:>7.4f} s {:>7.4f} s".format(numpy.mean(left_val), numpy.mean(right_val)))
52-
print("\t\tMedian: {:>7.4f} s {:>7.4f} s".format(numpy.quantile(left_val, 0.50), numpy.quantile(right_val, 0.50)))
53-
print("\t\t5%: {:>7.4f} s {:>7.4f} s".format(numpy.quantile(left_val, 0.05), numpy.quantile(right_val, 0.05)))
54-
print("\t\t95%: {:>7.4f} s {:>7.4f} s".format(numpy.quantile(left_val, 0.95), numpy.quantile(right_val, 0.95)))
55-
Y_left = numpy.asarray(Y_left,dtype=float).flatten()
56-
Y_right = numpy.asarray(Y_right,dtype=float).flatten()
57-
X = numpy.asarray(X,dtype=float).flatten()
51+
print("\t\tMedian: {:>7.4f} s {:>7.4f} s".format(
52+
numpy.quantile(left_val, 0.50), numpy.quantile(right_val, 0.50)))
53+
print("\t\t5%: {:>7.4f} s {:>7.4f} s".format(
54+
numpy.quantile(left_val, 0.05), numpy.quantile(right_val, 0.05)))
55+
print("\t\t95%: {:>7.4f} s {:>7.4f} s".format(
56+
numpy.quantile(left_val, 0.95), numpy.quantile(right_val, 0.95)))
57+
Y_left = numpy.asarray(Y_left, dtype=float).flatten()
58+
Y_right = numpy.asarray(Y_right, dtype=float).flatten()
59+
X = numpy.asarray(X, dtype=float).flatten()
5860

59-
cost_left = linregress(X, Y_left)
60-
cost_right = linregress(X, Y_right)
61+
cost_left = numpy.polyfit(X, Y_left, 1)
62+
cost_right = numpy.polyfit(X, Y_right, 1)
6163

6264
if args.s:
6365
print("")
64-
print("\tSlope {:>7.4f} ns {:>7.4f} ns".format(cost_left.slope * 1e6, cost_right.slope* 1e6))
65-
print("\tIntercept {:>7.4f} s {:>7.4f} s".format(cost_left.intercept, cost_right.intercept))
66-
67-
68-
66+
print("\tSlope {:>7.4f} us {:>7.4f} us".format(cost_left[0] * 1e6, cost_right[0] * 1e6))
67+
print("\tIntercept {:>7.4f} s {:>7.4f} s".format(cost_left[1], cost_right[1]))

benchmark/compare_commits.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function benchmark_branch {
1212
head=`git rev-parse --short HEAD`
1313
pip install .
1414
cd $wd
15-
taskset -c 0 python benchmark.py -o result-$1-$head.pkl
15+
python benchmark.py -o result-$1-$head.pkl
1616
}
1717

1818
sleep 5

benchmark/run.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@
99
#SBATCH --comment=no_monitoring
1010
#SBATCH --job-name benchmark_python
1111

12-
module load Python/3.6.4-intel-2018a
13-
module unload intel
14-
module load intel
12+
module load Python/3.8.6-GCCcore-10.2.0
13+
module load Score-P/7.0-gompic-2020b
1514

16-
export PATH=/scratch/rschoene/scorep-6-inst/bin:$PATH
15+
env_dir=~/virtenv/p-3.8.6-GCCcore-10.2.0-scorep-7.0-gompic-2020b/
1716

18-
. ~/scorep_binding_python/test/bin/activate
17+
if [ ! -d $env_dir ]
18+
then
19+
echo "Please create virtual env under: $env_dir"
20+
exit -1
21+
fi
1922

20-
srun python benchmark.py
23+
source $env_dir/bin/activate
24+
25+
srun compare_commits.sh master faster

0 commit comments

Comments
 (0)