-
-
Save jhamrick/7591855 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
# A template to demonstrate why we need to profile | |
# This instance written by Paul Ivanov (XXX: put your name / github id here) | |
import numpy as np | |
import random | |
def where_is_the_bottleneck(x): | |
return [random.randint(0, 100) for i in xrange(x)] | |
def could_be_this_one(x, y): | |
out = np.empty((x,)) | |
for i in xrange(int(x)): | |
out[i] = i * y | |
return out | |
def or_this_one(x): | |
out = [] | |
for i in xrange(int(x)): | |
out.append(random.randint(0, 100)) | |
def you(): | |
x = random.randint(0, 100) | |
for i in xrange(x): | |
continue | |
def will_have_to_profile(x): | |
while x > 1: | |
x = x / 2.0 | |
return x | |
def main(): | |
where_is_the_bottleneck(10) | |
could_be_this_one(3, 1000000) | |
or_this_one(9e5) | |
could_be_this_one(1000000, 3) | |
you() | |
will_have_to_profile(314159) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment