Commit aeea432a authored by Jason Madden's avatar Jason Madden

Make microbenchmarks run on recent versions; allow choosing alternate pythons...

Make microbenchmarks run on recent versions; allow choosing alternate pythons for easy comparison (E.g., using .tox/py[py]/bin/python.) [skip ci]
parent 1a7f4bcb
#!/bin/sh
set -e -x
python -c 'import gevent.core; from __future__ import print_function; print(gevent.__version__, gevent.core.get_version(), getattr(gevent.core, "get_method", lambda: "n/a")(), getattr(gevent, "get_hub", lambda: "n/a")())'
python -mtimeit -r 6 -s'obj = Exception(); obj.x=5' 'obj.x'
python -mtimeit -r 6 -s'from gevent import get_hub; get_hub()' 'get_hub()'
python -mtimeit -r 6 -s'from gevent import getcurrent' 'getcurrent()'
PYTHON=${PYTHON:=python}
$PYTHON -c 'from __future__ import print_function; import gevent.core; print(gevent.__version__, gevent.core.get_version(), getattr(gevent.core, "get_method", lambda: "n/a")(), getattr(gevent, "get_hub", lambda: "n/a")())'
$PYTHON -mtimeit -r 6 -s'obj = Exception(); obj.x=5' 'obj.x'
$PYTHON -mtimeit -r 6 -s'from gevent import get_hub; get_hub()' 'get_hub()'
$PYTHON -mtimeit -r 6 -s'from gevent import getcurrent' 'getcurrent()'
python -mtimeit -r 6 -s'from gevent.lock import Semaphore; s = Semaphore()' 's.release()'
python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); s.acquire()'
python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); s.acquire(); s.acquire(); s.acquire(); s.acquire()'
$PYTHON -mtimeit -r 6 -s'from gevent.lock import Semaphore; s = Semaphore()' 's.release()'
$PYTHON -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); s.acquire()'
$PYTHON -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); s.acquire(); s.acquire(); s.acquire(); s.acquire()'
python -mtimeit -r 6 -s'from gevent import spawn; f = lambda : 5' 'spawn(f)'
python -mtimeit -r 6 -s'from gevent import spawn; f = lambda : 5' 'spawn(f).join()'
python -mtimeit -r 6 -s'from gevent import spawn, run; from gevent.hub import xrange; f = lambda : 5' 'for _ in xrange(10000): spawn(f)' 'run()'
python -mtimeit -r 6 -s'from gevent import spawn_raw; f = lambda : 5' 'spawn_raw(f)'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; f = lambda : 5' 'spawn(f)'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; f = lambda : 5' 'spawn(f).join()'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn_raw; f = lambda : 5' 'spawn_raw(f)'
python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0)'
python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.0001)'
$PYTHON -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0)'
$PYTHON -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.0001)'
benchmarks/micro_run_callback.sh
benchmarks/micro_semaphore.sh
......
#!/bin/sh
set -e -x
python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda: 5' 'for _ in xrange(1000): g.link(l)'
python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(10): g.link(l);' 'g.join()'
python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(100): g.link(l);' 'g.join()'
python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(1000): g.link(l);' 'g.join()'
python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(10000): g.link(l);' 'g.join()'
python -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(100000): g.link(l);' 'g.join()'
PYTHON=${PYTHON:=python}
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda: 5' 'for _ in xrange(1000): g.link(l)'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(10): g.link(l);' 'g.join()'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(100): g.link(l);' 'g.join()'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(1000): g.link(l);' 'g.join()'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(10000): g.link(l);' 'g.join()'
$PYTHON -mtimeit -r 6 -s'from gevent import spawn; from gevent.hub import xrange; g = spawn(lambda: 5); l = lambda *args: 5' 'for _ in xrange(100000): g.link(l);' 'g.join()'
#!/bin/sh
set -e -x
python -mtimeit -r 6 -s'from gevent import run,get_hub; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'run_cb(f)'
python -mtimeit -r 6 -s'from gevent import run,get_hub; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'run_cb(f)' 'run()'
python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(100): run_cb(f)'
python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(100): run_cb(f)' 'run()'
python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(10000): run_cb(f)'
python -mtimeit -r 6 -s'from gevent import run,get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(10000): run_cb(f)' 'run()'
PYTHON=${PYTHON:=python}
$PYTHON -mtimeit -r 6 -s'from gevent import get_hub; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'run_cb(f)'
#$PYTHON -mtimeit -r 6 -s'from gevent import run,get_hub; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'run_cb(f)' 'run()'
$PYTHON -mtimeit -r 6 -s'from gevent import get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(100): run_cb(f)'
#$PYTHON -mtimeit -r 6 -s'from gevent import get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(100): run_cb(f)' 'run()'
$PYTHON -mtimeit -r 6 -s'from gevent import get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(10000): run_cb(f)'
#$PYTHON -mtimeit -r 6 -s'from gevent import get_hub; from gevent.hub import xrange; run_cb = get_hub().loop.run_callback; f = lambda : 5' 'for _ in xrange(10000): run_cb(f)' 'run()'
#!/bin/sh
set -e -x
python -mtimeit -r 6 -s'from gevent.lock import Semaphore; s = Semaphore()' 's.release()'
python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); s.acquire()'
python -mtimeit -r 6 -s'from gevent.coros import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); s.acquire(); s.acquire(); s.acquire(); s.acquire()'
PYTHON=${PYTHON:=python}
$PYTHON -mtimeit -r 6 -s'from gevent.lock import Semaphore; s = Semaphore()' 's.release()'
$PYTHON -mtimeit -r 6 -s'from gevent.lock import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); s.acquire()'
$PYTHON -mtimeit -r 6 -s'from gevent.lock import Semaphore; from gevent import spawn_raw; s = Semaphore(0)' 'spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); spawn_raw(s.release); s.acquire(); s.acquire(); s.acquire(); s.acquire()'
#!/bin/sh
set -e -x
python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0)'
python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.00001)'
python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.0001)'
python -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.001)'
PYTHON=${PYTHON:=python}
$PYTHON -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0)'
$PYTHON -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.00001)'
$PYTHON -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.0001)'
$PYTHON -mtimeit -r 6 -s'from gevent import sleep; f = lambda : 5' 'sleep(0.001)'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment