mitogen/tests/bench/fork.py

16 lines
328 B
Python
Raw Normal View History

2018-06-10 15:36:08 +00:00
"""
Measure latency of .fork() setup/teardown.
"""
import mitogen
import mitogen.core
2018-06-10 15:36:08 +00:00
@mitogen.main()
def main(router):
t0 = mitogen.core.now()
2018-06-10 15:36:08 +00:00
for x in xrange(200):
t = mitogen.core.now()
2018-06-10 15:36:08 +00:00
ctx = router.fork()
ctx.shutdown(wait=True)
print '++', 1000 * ((mitogen.core.now() - t0) / (1.0+x))