File: fork.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (21 lines) | stat: -rw-r--r-- 388 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
Measure latency of .fork() setup/teardown.
"""

import mitogen
import mitogen.core

try:
    xrange
except NameError:
    xrange = range


@mitogen.main()
def main(router):
    t0 = mitogen.core.now()
    for x in xrange(200):
        t = mitogen.core.now()
        ctx = router.fork()
        ctx.shutdown(wait=True)
    print('++ %d' % 1000 * ((mitogen.core.now() - t0) / (1.0+x)))