Skip to content

Instantly share code, notes, and snippets.

@drawks
Created February 17, 2012 21:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drawks/1855679 to your computer and use it in GitHub Desktop.
Save drawks/1855679 to your computer and use it in GitHub Desktop.
Really garbagy carbon-cache test bollus generator
#!/usr/bin/env python
import msgpack, socket, time, pickle, struct
from random import shuffle
words = [ word.strip() for word in open('/tmp/word.lst','rt').readlines() ]
def metric_name():
while True:
shuffle(words)
yield ".".join(words[0:3])
metric = metric_name()
def foo():
#s = socket.create_connection(('localhost',2005))
name = metric.next()
dps=[]
for second in xrange(int(time.time()-86400), int(time.time())):
dps.append((second,second))
num_c=round(len(dps)/500.0)
i = 0
while num_c - i:
work=dps[i:i+500]
pdata = pickle.dumps([ (name, datapoint) for datapoint in work ])
phead = struct.pack("!L",len(pdata))
pmsg = phead+pdata
pickle_f.write(pmsg)
nmmsg = msgpack.packb([name,work])
nmsgpack_f.write(nmmsg)
for dp in work:
msgpack.pack((name,dp),msgpack_f)
i+=1
pickle_f = open('/tmp/outfile.pickle','wb')
msgpack_f = open('/tmp/outfile.msgpack','wb')
nmsgpack_f = open('/tmp/outfile.nmsgpack','wb')
for i in range(0,100):
foo()
pickle_f.close()
msgpack_f.close()
nmsgpack_f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment