Skip to content

Commit 76000c3

Browse files
committed
Extend benchmark
1 parent eef310a commit 76000c3

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

benchmark.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gc
12
import timeit
23

34

@@ -44,22 +45,44 @@
4445
key = upstr('key10')
4546
"""
4647

48+
upstr_from_upstr = """\
49+
upstr(val)
50+
"""
51+
52+
make_upstr = """\
53+
val = upstr('VaLuE')
54+
"""
55+
4756
print("Cython setitem str: {:.3f} sec".format(
4857
timeit.timeit(setitem, cython_multidict+fill)))
58+
gc.collect()
4959

5060
print("Python setitem str: {:.3f} sec".format(
5161
timeit.timeit(setitem, python_multidict+fill)))
62+
gc.collect()
5263

5364

5465
print("Cython getitem str: {:.3f} sec".format(
5566
timeit.timeit(getitem, cython_multidict+fill)))
67+
gc.collect()
5668

5769
print("Python getitem str: {:.3f} sec".format(
5870
timeit.timeit(getitem, python_multidict+fill)))
71+
gc.collect()
5972

6073

6174
print("Cython getitem upstr: {:.3f} sec".format(
6275
timeit.timeit(getitem, cython_cimultidict+fill)))
76+
gc.collect()
6377

6478
print("Python getitem upstr: {:.3f} sec".format(
6579
timeit.timeit(getitem, python_cimultidict+fill)))
80+
gc.collect()
81+
82+
print("Cython upstr from upstr: {:.3f} sec".format(
83+
timeit.timeit(upstr_from_upstr, cython_cimultidict+make_upstr)))
84+
gc.collect()
85+
86+
print("Python upstr from upstr: {:.3f} sec".format(
87+
timeit.timeit(upstr_from_upstr, python_cimultidict+make_upstr)))
88+
gc.collect()

0 commit comments

Comments
 (0)