mitogen/tests/bench/roundtrip.py

30 lines
500 B
Python
Raw Normal View History

2018-06-10 15:36:08 +00:00
"""
Measure latency of local RPC.
"""
import time
import mitogen
import mitogen.utils
import ansible_mitogen.affinity
mitogen.utils.setup_gil()
ansible_mitogen.affinity.policy.assign_worker()
try:
xrange
except NameError:
xrange = range
2018-06-10 15:36:08 +00:00
def do_nothing():
pass
@mitogen.main()
def main(router):
f = router.fork()
f.call(do_nothing)
2018-06-10 15:36:08 +00:00
t0 = time.time()
for x in xrange(20000):
2018-06-10 15:36:08 +00:00
f.call(do_nothing)
print('++', int(1e6 * ((time.time() - t0) / (1.0+x))), 'usec')