Last active
March 5, 2017 02:41
-
-
Save jtallieu/371f9f3d3a3474d42ff59a324b6bad9b to your computer and use it in GitHub Desktop.
Gevent latency benchmark script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import gevent | |
import timeit | |
from gevent.event import Event | |
from plotter import graph_latency, graph_ops | |
RUNS = [100, 500, 1000, 5000, 10000, 20000, 30000, 60000, 100000, 120000, 150000] | |
start_event = Event() | |
greenlets = [] | |
times = [] | |
def counter(id): | |
global times | |
start_event.wait() | |
times.append(timeit.default_timer()) | |
return | |
def run(threads): | |
print "----------------------------------------" | |
print "Running {} threads".format(threads) | |
print "----------------------------------------" | |
start_event.clear() | |
for x in range(0, threads): | |
greenlets.append(gevent.spawn(counter, x)) | |
print "starting {} greenlets".format(threads) | |
start_time = timeit.default_timer() | |
start_event.set() | |
gevent.wait(greenlets) | |
for i, end_time in enumerate(times): | |
times[i] = end_time - start_time | |
if __name__ == "__main__": | |
series = [] | |
for threads in RUNS: | |
run(threads) | |
series.append({ | |
'name': "{}".format(threads), | |
'data': times | |
}) | |
greenlets = [] | |
times = [] | |
title = "Greenlet Latency - All ready" | |
fname = "latency-single" | |
graph_latency(fname, {'title': title, 'series': series}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment