| 45 | |
| 46 | @app.task(cur=0, time_start=None, queue='bench.worker', bare=True) |
| 47 | def it(_, n): |
| 48 | # use internal counter, as ordering can be skewed |
| 49 | # by previous runs, or the broker. |
| 50 | i = it.cur |
| 51 | if i and not i % 5000: |
| 52 | print(f'({i} so far: {tdiff(it.subt)}s)', file=sys.stderr) |
| 53 | it.subt = time.monotonic() |
| 54 | if not i: |
| 55 | it.subt = it.time_start = time.monotonic() |
| 56 | elif i > n - 2: |
| 57 | total = tdiff(it.time_start) |
| 58 | print(f'({i} so far: {tdiff(it.subt)}s)', file=sys.stderr) |
| 59 | print('-- process {} tasks: {}s total, {} tasks/s'.format( |
| 60 | n, total, n / (total + .0), |
| 61 | )) |
| 62 | import os |
| 63 | os._exit(0) |
| 64 | it.cur += 1 |
| 65 | |
| 66 | |
| 67 | def bench_apply(n=DEFAULT_ITS): |