Created
January 31, 2012 18:35
-
-
Save felipe-prenholato/1712079 to your computer and use it in GitHub Desktop.
Tests uuid generation and search DICT vs LIST
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
###################### DICT ############################################ | |
(p1)felipe@PLAPSTMD142:~/projects/p1/portal$ time python ~/uuid_tests_dict.py | |
50000 (50000) | |
0:00:06.289915 from last step | |
0:00:06.289915 until now | |
100000 (100000) | |
0:00:08.337636 from last step | |
0:00:14.627551 until now | |
150000 (150000) | |
0:00:10.559169 from last step | |
0:00:25.186720 until now | |
200000 (200000) | |
0:00:06.269067 from last step | |
0:00:31.455787 until now | |
250000 (250000) | |
0:00:06.269273 from last step | |
0:00:37.725060 until now | |
real 0m37.859s | |
user 0m25.154s | |
sys 0m6.252s | |
############### LIST ###################################### | |
(p1)felipe@PLAPSTMD142:~/projects/p1/portal$ time python ~/uuid_tests.py | |
50000 (50000) | |
0:00:35.839977 from last step | |
0:00:35.839977 until now | |
100000 (100000) | |
0:01:27.650370 from last step | |
0:02:03.490347 until now | |
150000 (150000) | |
0:02:37.392966 from last step | |
0:04:40.883313 until now | |
200000 (200000) | |
0:03:29.078462 from last step | |
0:08:09.961775 until now | |
250000 (250000) | |
0:04:32.285919 from last step | |
0:12:42.247694 until now | |
real 12m42.332s | |
user 11m3.221s | |
sys 0m12.533s |
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
import uuid | |
import datetime | |
dstart = datetime.datetime.now() | |
last_step = dstart | |
uuids = {} | |
i = 0 | |
while True: | |
u = uuid.uuid5(uuid.uuid1(),uuid.uuid1().hex).hex.upper() | |
if u not in uuids: | |
uuids[u] = None | |
i+=1 | |
if i%50000 == 0: | |
now = datetime.datetime.now() | |
print "%s (%s)" % (i,len(uuids.keys())) | |
print "%s from last step" % (now-last_step) | |
print "%s until now" % (now-dstart) | |
last_step = now | |
if i == (50000*5): | |
break | |
else: | |
print u | |
print "started %s" % dstart | |
print "finished %s" % datetime.datetime.now() | |
print "Time runnning %s" % (datetime.datetime.now()-dstart) | |
print "Generated %s uuids" % len(uuids.keys()) | |
break |
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
import uuid | |
import datetime | |
dstart = datetime.datetime.now() | |
last_step = dstart | |
uuids = [] | |
i = 0 | |
while True: | |
u = uuid.uuid5(uuid.uuid1(),uuid.uuid1().hex).hex.upper() | |
if u not in uuids: | |
uuids.append(u) | |
i+=1 | |
if i%50000 == 0: | |
now = datetime.datetime.now() | |
print "%s (%s)" % (i,len(uuids)) | |
print "%s from last step" % (now-last_step) | |
print "%s until now" % (now-dstart) | |
last_step = now | |
if i == (50000*5): | |
break | |
else: | |
print u | |
print "started %s" % dstart | |
print "finished %s" % datetime.datetime.now() | |
print "Time runnning %s" % (datetime.datetime.now()-dstart) | |
print "Generated %s uuids" % len(uuids) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment