Skip to content

Commit 2707ae0

Browse files
AJMansfielddpgeorge
authored andcommitted
tests/internal_bench/var: Benchmark ordered map accesses.
This adds an internal_bench benchmark that benchmarks ordered map linear scan cache performance. Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent d28844d commit 2707ae0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import bench
2+
3+
4+
def test(num):
5+
i = 0
6+
o = set() # object with largest rom-frozen ordered locals_dict
7+
n = "__contains__" # last element in that dict for longest lookup
8+
while i < num:
9+
i += hasattr(o, n) # True, converts to 1
10+
11+
12+
bench.run(test)

0 commit comments

Comments
 (0)