Skip to content

Commit 4d6d704

Browse files
committed
benchmark: added way to plot from json directly
1 parent becafb5 commit 4d6d704

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,5 @@ cython_debug/
162162
#.kate-swp
163163

164164
.vscode/
165+
time_taken_for_various*
166+

model/distributions/sphere/watson/benchmark_fib_starts.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'''
77

88
import json
9+
import os
910
from pathlib import Path
1011
import plotly.express as px
1112
from model.distributions.sphere.watson.fibonachi import WatsonFibonachiSampling
@@ -115,6 +116,11 @@ def _plot_rows(rows, title, filename, x_label, log_x=False, log_y=False):
115116
x=0,
116117
)
117118
)
119+
if log_x:
120+
fig.update_xaxes(dtick=1)
121+
if log_y:
122+
fig.update_yaxes(dtick=1)
123+
118124
try:
119125
fig.write_image(f"{_sanitize_filename(filename)}.svg")
120126
except Exception as e:
@@ -170,6 +176,21 @@ def plot_benches(results, title=None, filename=None, x_label=None, log_x=None, l
170176

171177

172178
if __name__ == "__main__":
179+
plot_from_json = os.getenv("PLOT_FROM_JSON")
180+
if plot_from_json:
181+
if plot_from_json != "1":
182+
json_paths = [p.strip() for p in plot_from_json.split(",") if p.strip()]
183+
else:
184+
json_paths = [
185+
f"{_sanitize_filename('time taken for various kappa values (10000 samples)')}.json",
186+
f"{_sanitize_filename('time taken for various kappa values log scale (10000 samples)')}.json",
187+
f"{_sanitize_filename('time taken for various sample counts log scale (kappa=10)')}.json",
188+
f"{_sanitize_filename('time taken for various sample counts log scale (kappa=-10)')}.json",
189+
]
190+
for json_path in json_paths:
191+
plot_benches(json_path)
192+
raise SystemExit(0)
193+
173194
runner = pyperf.Runner()
174195

175196

0 commit comments

Comments
 (0)