Skip to content

Commit ff62d46

Browse files
committed
Separated comparision subplot images, and changed bootstrap statistic to use medians
Signed-off-by: Vedant <[email protected]>
1 parent 195bae6 commit ff62d46

File tree

2 files changed

+39
-28
lines changed

2 files changed

+39
-28
lines changed

libs/core/testing/src/performance.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,13 @@ average: {{average(elapsed)}}{{^-last}}
181181
<< "\n\n";
182182
}
183183
if (print_cdash_img)
184-
strm << "<CTestMeasurementFile type=\"image/png\" "
185-
"name=\"TestImage\" >"
186-
<< "./" << test_name_
187-
<< ".png</CTestMeasurementFile>\n";
184+
{
185+
for (std::size_t i = 0; i < obj.m_map.size(); i++)
186+
strm << "<CTestMeasurementFile type=\"image/png\" "
187+
"name=\"perftest\" >"
188+
<< "./" << test_name_ << "_" << i
189+
<< ".png</CTestMeasurementFile>\n";
190+
}
188191
}
189192
return strm;
190193
}
@@ -222,9 +225,12 @@ average: {{average(elapsed)}}{{^-last}}
222225
{
223226
detail::bench().render(templ, strm);
224227
if (!detailed_ && print_cdash_img)
225-
strm << "<CTestMeasurementFile type=\"image/png\" "
226-
"name=\"TestImage\">"
227-
<< "./" << test_name_ << ".png</CTestMeasurementFile>\n";
228+
{
229+
for (long unsigned int i = 0; i < detail::bench().results().size(); i++)
230+
strm << "<CTestMeasurementFile type=\"image/png\" "
231+
"name=\"perftest\">"
232+
<< "./" << test_name_ << "_" << i << ".png</CTestMeasurementFile>\n";
233+
}
228234
}
229235

230236
// Overload that uses a default nanobench template

tools/perftests_plot.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
sns.set_style("ticks",{'axes.grid' : True})
1111

12-
def mean_statistic(sample1, sample2, axis=-1):
13-
mean1 = np.mean(sample1, axis=axis)
14-
mean2 = np.mean(sample2, axis=axis)
15-
return (mean1 - mean2) / mean1
12+
def median_statistic(sample1, sample2, axis=-1):
13+
median1 = np.median(sample1, axis=axis)
14+
median2 = np.median(sample2, axis=axis)
15+
return (median2 - median1) / median1
1616

1717
rng = np.random.default_rng()
1818

@@ -33,9 +33,9 @@ def mean_statistic(sample1, sample2, axis=-1):
3333
samples = []
3434

3535
header_flag = True
36-
n = ceil(len(json_obj1["outputs"]) / 2)
37-
fig, ax = plt.subplots(2, n, figsize=(5 * n, 6), sharey=False)
38-
plt.subplots_adjust(hspace=0.3)
36+
# n = ceil(len(json_obj1["outputs"]) / 2)
37+
# fig, ax = plt.subplots(2, n, figsize=(5 * n, 6), sharey=False)
38+
# plt.subplots_adjust(hspace=0.3)
3939
i = 0
4040
for test1, test2 in zip(json_obj1["outputs"], json_obj2["outputs"]):
4141
if test1["name"] == test2["name"]:
@@ -48,22 +48,27 @@ def mean_statistic(sample1, sample2, axis=-1):
4848
samples.append(test1["series"])
4949

5050
data = (test2["series"], test1["series"])
51-
res = scipy.stats.bootstrap(data, mean_statistic, method='basic', random_state=rng)
51+
res = scipy.stats.bootstrap(data, median_statistic, method='basic', random_state=rng)
5252

5353
mean2 = np.mean(test2["series"])
5454
mean1 = np.mean(test1["series"])
5555

56-
if n != 1:
57-
curr_plot = ax[i // n, i % n]
58-
else:
59-
curr_plot = ax[i]
56+
# if n != 1:
57+
# curr_plot = ax[i // n, i % n]
58+
# else:
59+
# curr_plot = ax[i]
6060

61-
sns.kdeplot(test2["series"], fill=True, ax=curr_plot, label='baseline')
62-
sns.kdeplot(test1["series"], fill=True, ax=curr_plot, label='current')
63-
curr_plot.axvline(mean2, label='baseline mean', color='k')
64-
curr_plot.axvline(mean1, label='current mean', color='g')
65-
curr_plot.legend()
66-
curr_plot.set_title(f'{test1["name"]}, {test1["executor"]}')
61+
plt.figure(figsize=(8, 4))
62+
63+
sns.kdeplot(test2["series"], fill=True, label='baseline')
64+
sns.kdeplot(test1["series"], fill=True, label='current')
65+
plt.axvline(mean2, label='baseline mean', color='k')
66+
plt.axvline(mean1, label='current mean', color='g')
67+
plt.legend()
68+
plt.suptitle(f'{test1["name"]}, \n{test1["executor"]}')
69+
70+
plt.tight_layout()
71+
plt.savefig(f"{sys.argv[3]}_{i}.png")
6772

6873
percentage_diff = ((mean2 - mean1) / mean2) * 100
6974

@@ -88,7 +93,7 @@ def mean_statistic(sample1, sample2, axis=-1):
8893

8994
html_file.close()
9095

91-
plt.tight_layout()
92-
[fig.delaxes(a) for a in ax.flatten() if not a.has_data()]
93-
plt.savefig(sys.argv[3] + ".png")
96+
# plt.tight_layout()
97+
# [fig.delaxes(a) for a in ax.flatten() if not a.has_data()]
98+
# plt.savefig(sys.argv[3] + ".png")
9499

0 commit comments

Comments
 (0)