Created
December 26, 2011 23:35
-
-
Save sweenzor/1522293 to your computer and use it in GitHub Desktop.
Investigating memory using of python Queues
This file contains 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/env python | |
import Queue | |
import json | |
import random | |
import time | |
import psutil | |
def random_message(): | |
"""create a dict of junk data, return as json""" | |
msg = {} | |
for i in range(9): | |
msg[random.random()] = random.random() | |
return json.dumps(msg) | |
q = Queue.LifoQueue() | |
counter = 0 | |
while True: | |
counter += 1 | |
q.put(random_message()) | |
time.sleep(0.01) | |
if counter % 1000 == 0: | |
print 'queue size', q.qsize() | |
print psutil.phymem_usage() | |
print '\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment