|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
# Verify _receive_one() quadratic behaviour fixed.
|
|
|
|
|
'Measure throughput of messages.'
|
|
|
|
|
|
|
|
|
|
import mitogen
|
|
|
|
|
import mitogen.core
|
|
|
|
|
@ -6,20 +6,27 @@ import mitogen.core
|
|
|
|
|
|
|
|
|
|
@mitogen.main()
|
|
|
|
|
def main(router):
|
|
|
|
|
c = router.fork()
|
|
|
|
|
import optparse
|
|
|
|
|
parser = optparse.OptionParser(description=__doc__)
|
|
|
|
|
parser.add_option(
|
|
|
|
|
'-i', '--iterations', type=int, metavar='N', default=10,
|
|
|
|
|
help='Number of iterations (default %default)')
|
|
|
|
|
parser.add_option('--debug', action='store_true')
|
|
|
|
|
opts, args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
c = router.fork(debug=opts.debug)
|
|
|
|
|
|
|
|
|
|
n = 1048576 * 127
|
|
|
|
|
s = ' ' * n
|
|
|
|
|
print('bytes in %.2fMiB string...' % (n/1048576.0),)
|
|
|
|
|
|
|
|
|
|
t0 = mitogen.core.now()
|
|
|
|
|
for x in range(10):
|
|
|
|
|
for x in range(opts.iterations):
|
|
|
|
|
tt0 = mitogen.core.now()
|
|
|
|
|
assert n == c.call(len, s)
|
|
|
|
|
print('took %dms' % (1000 * (mitogen.core.now() - tt0),))
|
|
|
|
|
|
|
|
|
|
t1 = mitogen.core.now()
|
|
|
|
|
print('total %dms / %dms avg / %.2fMiB/sec' % (
|
|
|
|
|
1000 * (t1 - t0),
|
|
|
|
|
(1000 * (t1 - t0)) / (x + 1),
|
|
|
|
|
((n * (x + 1)) / (t1 - t0)) / 1048576.0,
|
|
|
|
|
))
|
|
|
|
|
mean = (t1 - t0) / opts.iterations
|
|
|
|
|
transferred_size = n * opts.iterations
|
|
|
|
|
transfer_rate = transferred_size / (t1 - t0)
|
|
|
|
|
print('++ iterations %d, mean %.03f ms, rate %.03f MiB/s'
|
|
|
|
|
% (opts.iterations, 1e3 * mean, transfer_rate / 2**20))
|
|
|
|
|
|