-
-
Save ericosur/187c40b6cb370f147ac4ffe99002f7ab to your computer and use it in GitHub Desktop.
sum using python vanilla or numpy
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
#!/usr/bin/python3.6 | |
# coding: utf-8 | |
''' | |
brief description for this script | |
''' | |
import time | |
import numpy as np | |
def main(): | |
''' main ''' | |
start_time = time.time() | |
count = 1000000000 | |
normalRange = np.arange(count) | |
print(normalRange.sum()) | |
print('time taken: {} seconds'.format(time.time() - start_time)) | |
if __name__ == '__main__': | |
main() |
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
#!/usr/bin/python3.6 | |
# coding: utf-8 | |
''' | |
brief description for this script | |
''' | |
import time | |
def main(): | |
''' main ''' | |
start_time = time.time() | |
count = 1000000000 | |
normalRange = range(count) | |
print(sum(normalRange)) | |
print('time taken: {} seconds'.format(time.time() - start_time)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
merge these two gist into one script and then benchmark