Skip to content

Commit e32711a

Browse files
committed
Add simple python version of benchmarks
1 parent 3dbd14e commit e32711a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bench/bench.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from functools import reduce
2+
from textwrap import dedent as dd
3+
from timeit import repeat
4+
5+
6+
sources = ["canada", "citm_catalog", "citylots", "twitter"]
7+
8+
min_times = []
9+
for source in sources:
10+
s = dd(f"""\
11+
with open("../data/{source}.json") as f:
12+
json.load(f)""")
13+
times = repeat(stmt=s, setup="import json", repeat=3, number=1)
14+
t = reduce(min, times)
15+
print(f"{source} {t:0.06f} seconds")
16+
min_times.append(t)
17+
18+
geo_mean = reduce(lambda a, b: a*b, min_times)**(1/len(min_times))
19+
print(f"Total (G.M): {geo_mean:0.06f}")

0 commit comments

Comments
 (0)