2018-06-10 15:36:08 +00:00
|
|
|
"""
|
|
|
|
Measure latency of local RPC.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
2019-01-23 12:44:08 +00:00
|
|
|
import mitogen
|
|
|
|
import mitogen.utils
|
2019-02-01 14:33:14 +00:00
|
|
|
import ansible_mitogen.affinity
|
2019-01-23 12:44:08 +00:00
|
|
|
|
|
|
|
mitogen.utils.setup_gil()
|
2019-02-01 14:33:14 +00:00
|
|
|
ansible_mitogen.affinity.policy.assign_worker()
|
2018-11-04 19:43:52 +00:00
|
|
|
|
|
|
|
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()
|
2018-11-04 19:43:52 +00:00
|
|
|
f.call(do_nothing)
|
2018-06-10 15:36:08 +00:00
|
|
|
t0 = time.time()
|
2018-11-04 19:43:52 +00:00
|
|
|
for x in xrange(20000):
|
2018-06-10 15:36:08 +00:00
|
|
|
f.call(do_nothing)
|
2018-11-04 19:43:52 +00:00
|
|
|
print('++', int(1e6 * ((time.time() - t0) / (1.0+x))), 'usec')
|