Skip to content

Commit 1d0a0b9

Browse files
add method_caller benchmark to ftscalingbench.py
1 parent f9d2f28 commit 1d0a0b9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Tools/ftscalingbench/ftscalingbench.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import sys
2828
import threading
2929
import time
30+
from operator import methodcaller
3031

3132
# The iterations in individual benchmarks are scaled by this factor.
3233
WORK_SCALE = 100
@@ -188,6 +189,18 @@ def thread_local_read():
188189
_ = tmp.x
189190
_ = tmp.x
190191

192+
class MyClass:
193+
__slots__ = ()
194+
195+
def func(self):
196+
pass
197+
198+
@register_benchmark
199+
def method_caller():
200+
mc = methodcaller("func")
201+
obj = MyClass()
202+
for i in range(1000 * WORK_SCALE):
203+
mc(obj)
191204

192205
def bench_one_thread(func):
193206
t0 = time.perf_counter_ns()

0 commit comments

Comments
 (0)