Skip to content

Commit b2fb5ec

Browse files
committed
Add free-threading scaling bm
1 parent c35c735 commit b2fb5ec

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Tools/ftscalingbench/ftscalingbench.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import sys
2828
import threading
2929
import time
30+
import copy
3031

3132
# The iterations in individual benchmarks are scaled by this factor.
3233
WORK_SCALE = 100
@@ -37,11 +38,25 @@
3738
in_queues = []
3839
out_queues = []
3940

40-
4141
def register_benchmark(func):
4242
ALL_BENCHMARKS[func.__name__] = func
4343
return func
4444

45+
46+
@register_benchmark
47+
def shallow_copy():
48+
x = [1, 2, 3]
49+
shallow_copy = copy.copy
50+
for i in range(200 * WORK_SCALE):
51+
shallow_copy(x)
52+
53+
@register_benchmark
54+
def deepcopy():
55+
x = {'list': [1, 2], 'tuple': (1, None)}
56+
deepcopy = copy.deepcopy
57+
for i in range(40 * WORK_SCALE):
58+
deepcopy(x)
59+
4560
@register_benchmark
4661
def object_cfunction():
4762
accu = 0

0 commit comments

Comments
 (0)