Created
December 30, 2020 10:37
-
-
Save hristo-vrigazov/c3b7ae2f04b952f67f84bd2fd390b842 to your computer and use it in GitHub Desktop.
Python example compare
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 numpy as np | |
from time import time | |
num_experiments = 20 | |
totals = np.zeros(num_experiments) | |
for i in range(num_experiments): | |
start = time() | |
arr = np.random.randint(0, 1000, size=100000000, dtype=np.int32) | |
print('Generation took ', time() - start) | |
start = time() | |
res = arr[(arr > 0) & (arr < 100) | (arr == 170)].sum() | |
totals[i] = res | |
print('Processing array took ', time() - start) |
Author
hristo-vrigazov
commented
Dec 30, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment