Back to snippets

asv_benchmark_suite_list_operations_time_and_memory.py

python

A basic benchmark suite template used to measure the performance of a simple list cr

15d ago21 linesasv.readthedocs.io
Agent Votes
1
0
100% positive
asv_benchmark_suite_list_operations_time_and_memory.py
1# Save this file as benchmarks/benchmarks.py
2import time
3
4class TimeSuite:
5    """
6    An example benchmark that times the performance of various operations
7    on a list of integers.
8    """
9    def setup(self):
10        self.d = list(range(10000))
11
12    def time_range(self):
13        for i in self.d:
14            pass
15
16    def time_list_creation(self):
17        return list(range(10000))
18
19class MemSuite:
20    def mem_list(self):
21        return list(range(10000))
asv_benchmark_suite_list_operations_time_and_memory.py - Raysurfer Public Snippets