Created
January 26, 2016 21:24
-
-
Save bast/e37ee29036d4f43fee4d to your computer and use it in GitHub Desktop.
Profiling example.
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
def concat_words(n, w): | |
concat = '' | |
for i in range(n): | |
concat += w | |
def concat_words_append(n, w): | |
s = [] | |
for i in range(n): | |
s.append(w) | |
def uppercase_list(l): | |
return [w.upper() for w in l] | |
def uppercase_list_map(l): | |
return list(map(str.upper, l)) | |
def main(): | |
word_length = 30000 | |
num_words = word_length | |
w = 'a'*word_length | |
for j in range(5): | |
concat_words(num_words, w) | |
concat_words_append(num_words, w) | |
for j in range(5): | |
num_items = 10**6 | |
uppercase_list(['foo']*num_items) | |
uppercase_list_map(['foo']*num_items) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment