mitogen/tests/timing_test.py

24 lines
481 B
Python
Raw Normal View History

2016-08-26 19:10:25 +00:00
#!/usr/bin/env python
import socket
import time
import unittest
2017-09-16 07:15:25 +00:00
import mitogen.master
import mitogen.utils
2016-08-26 19:10:25 +00:00
2017-09-16 07:15:25 +00:00
@mitogen.utils.with_broker
2016-08-26 19:10:25 +00:00
def do_stuff(broker):
2017-09-16 07:15:25 +00:00
context = mitogen.master.connect(broker)
2016-08-26 19:10:25 +00:00
t0 = time.time()
ncalls = 1000
for x in xrange(ncalls):
context.call(socket.gethostname)
return (1e6 * (time.time() - t0)) / ncalls
class LocalContextTimingTest(unittest.TestCase):
def test_timing(self):
self.assertLess(do_stuff(), 1000)