Created
August 9, 2012 08:55
-
-
Save silegon/3302464 to your computer and use it in GitHub Desktop.
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 random | |
def get_random_list(list_len): | |
list_range = list_len * 4 | |
return random.sample(xrange(-list_range, list_range), list_len) | |
def test_set(random_list): | |
t_set = set() | |
for i in random_list: | |
t_set.add(i) | |
print "test_set" | |
return | |
def test_list_set(random_list): | |
t_list = [] | |
for i in random_list: | |
t_list.append(i) | |
t_list_set = set(t_list) | |
print "test_list_set" | |
return | |
def test_list(random_list): | |
t_list = [] | |
for i in random_list: | |
t_list.append(i) | |
print "test_list" | |
return | |
if __name__ == '__main__': | |
list_len = 1000000 | |
random_list = get_random_list(list_len) | |
import cProfile | |
cProfile.run("test_set(random_list)") | |
cProfile.run("test_list_set(random_list)") | |
cProfile.run("test_list(random_list)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment