Source code for benchmarks.benchmarks
# Write the benchmarking functions here.
# See "Writing benchmarks" in the asv docs for more information.
[docs]
class TimeSuite:
"""
An example benchmark that times the performance of various kinds
of iterating over dictionaries in Python.
"""
[docs]
def setup(self):
self.d = {}
for x in range(500):
self.d[x] = None
[docs]
def time_keys(self):
for key in self.d.keys():
pass
[docs]
def time_values(self):
for value in self.d.values():
pass
[docs]
def time_range(self):
d = self.d
for key in range(500):
d[key]
[docs]
class MemSuite:
[docs]
def mem_list(self):
return [0] * 256