diff options
| author | Ryan Williams <breath@alum.mit.edu> | 2010-04-11 19:36:05 -0700 |
|---|---|---|
| committer | Ryan Williams <breath@alum.mit.edu> | 2010-04-11 19:36:05 -0700 |
| commit | f02d532ccccf78c29e628abd0080ee80f526d8a4 (patch) | |
| tree | 7893df731fd835182481ed0f6f68923fb3efa1c7 /benchmarks/spawn_plot.py | |
| parent | 99caa2c6a6b1672f8baa6c0d4b892d72b6214f8c (diff) | |
| download | eventlet-f02d532ccccf78c29e628abd0080ee80f526d8a4.tar.gz | |
Adding spawn_plot.py, which outputs in a format that hudson's plot plugin understands.
Diffstat (limited to 'benchmarks/spawn_plot.py')
| -rw-r--r-- | benchmarks/spawn_plot.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/benchmarks/spawn_plot.py b/benchmarks/spawn_plot.py new file mode 100644 index 0000000..1c5b40c --- /dev/null +++ b/benchmarks/spawn_plot.py @@ -0,0 +1,86 @@ +#!/usr/bin/env python +''' + Compare spawn to spawn_n, among other things. + + This script will generate a number of "properties" files for the + Hudson plot plugin +''' +from __future__ import with_statement + +import os +import eventlet +import benchmarks + +DATA_DIR = 'plot_data' + +if not os.path.exists(DATA_DIR): + os.makedirs(DATA_DIR) + +def write_result(filename, best): + with open(os.path.join(DATA_DIR, filename), 'w') as fd: + fd.write('YVALUE=%s' % best) + +def cleanup(): + eventlet.sleep(0.2) + +iters = 10000 +best = benchmarks.measure_best(5, iters, + 'pass', + cleanup, + eventlet.sleep) + +write_result('eventlet.sleep_main', best[eventlet.sleep]) + +gt = eventlet.spawn(benchmarks.measure_best,5, iters, + 'pass', + cleanup, + eventlet.sleep) +best = gt.wait() +write_result('eventlet.sleep_gt', best[eventlet.sleep]) + +def dummy(i=None): + return i + +def run_spawn(): + eventlet.spawn(dummy, 1) + +def run_spawn_n(): + eventlet.spawn_n(dummy, 1) + +def run_spawn_n_kw(): + eventlet.spawn_n(dummy, i=1) + + +best = benchmarks.measure_best(5, iters, + 'pass', + cleanup, + run_spawn_n, + run_spawn, + run_spawn_n_kw) +write_result('eventlet.spawn', best[run_spawn]) +write_result('eventlet.spawn_n', best[run_spawn_n]) +write_result('eventlet.spawn_n_kw', best[run_spawn_n_kw]) + +pool = None +def setup(): + global pool + pool = eventlet.GreenPool(iters) + +def run_pool_spawn(): + pool.spawn(dummy, 1) + +def run_pool_spawn_n(): + pool.spawn_n(dummy, 1) + +def cleanup_pool(): + pool.waitall() + + +best = benchmarks.measure_best(3, iters, + setup, + cleanup_pool, + run_pool_spawn, + run_pool_spawn_n, +) +write_result('eventlet.GreenPool.spawn', best[run_pool_spawn]) +write_result('eventlet.GreenPool.spawn_n', best[run_pool_spawn_n]) |
