Created
November 19, 2012 21:02
-
-
Save tsuna/4113855 to your computer and use it in GitHub Desktop.
Trivial script to load random data in OpenTSDB as quickly as possible.
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
#!/usr/bin/python | |
import os | |
import socket | |
import sys | |
import time | |
ITERATIONS = 4000 | |
TAGS = 50 | |
pid = os.getpid() | |
tsd = socket.socket() | |
tsd.connect(('127.0.0.1', 4242)) | |
start = time.time() | |
def rate(iteration): | |
timing = time.time() - start | |
n = iteration * TAGS | |
return "%d in %f secs: %d/s" % (n, timing, n / timing) | |
for i in xrange(ITERATIONS): | |
ts = 1200000000 + i | |
#print "%d.." % (i * TAGS), | |
sys.stdout.flush() | |
buf = "\n".join("put test.sample %d %d tag1=aa%d tag2=bb%d" | |
% (ts, j, j, j) | |
for j in xrange(TAGS)) | |
tsd.sendall(buf + "\n") | |
if i and i % 1000 == 0: | |
print "[%d] %s" % (pid, rate(i)) | |
tsd.close() | |
print "[%d] Done: %s" % (pid, rate(ITERATIONS)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment