Created
March 7, 2012 02:28
-
-
Save derpston/1990503 to your computer and use it in GitHub Desktop.
Metricfire Python benchmarking
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 metricfire | |
import time | |
# Send to a nonexistant Metricfire aggregation server on this machine. | |
metricfire.init("deadbeef-dead-beef-dead-deadcafebabe", server = "127.0.0.1:6334") | |
before = time.time() | |
for index in xrange(100000): | |
pass | |
after = time.time() | |
plain_usecs_per_iteration = (after - before) / 100000 * 1000000 | |
print "100k iterations in %fs, %fus per iteration" % (after - before, plain_usecs_per_iteration) | |
before = time.time() | |
for index in xrange(100000): | |
metricfire.send("test", 1) | |
after = time.time() | |
send_usecs_per_iteration = (after - before) / 100000 * 1000000 | |
print "100k iterations in %fs, %fus per iteration" % (after - before, send_usecs_per_iteration) | |
def foo(): | |
pass | |
@metricfire.measure | |
def foo2(): | |
pass | |
before = time.time() | |
for index in xrange(100000): | |
foo() | |
after = time.time() | |
usecs_per_call = (after - before) / 100000 * 1000000 | |
print "100k calls in %fs, %fus per call" % (after - before, usecs_per_call) | |
before = time.time() | |
for index in xrange(100000): | |
foo2() | |
after = time.time() | |
decorated_usecs_per_call = (after - before) / 100000 * 1000000 | |
print "100k decorated calls in %fs, %fus per call" % (after - before, decorated_usecs_per_call) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results from an
Intel(R) Core(TM) i7 CPU 950 @ 3.07GHz