Last active
January 10, 2021 17:13
-
-
Save sjp38/93148febf88b0a3c2662d29994964762 to your computer and use it in GitHub Desktop.
This file contains 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
$ cat test.py | |
#!/usr/bin/env python3 | |
import datetime | |
import random | |
dividends = [] | |
divisors = [] | |
for i in range(1000 * 1000): | |
dividends.append(random.randint(1,1000000000)) | |
divisors.append(random.randint(1,1000000000)) | |
start_time = datetime.datetime.now() | |
print('start') | |
for i in range(100): | |
for j in range(len(dividends)): | |
dividends[j] = dividends[j] // divisors[j] | |
print(datetime.datetime.now() - start_time) | |
$ for i in {1..5}; do ./test.py; done | |
start | |
0:00:15.669361 | |
start | |
0:00:21.611676 | |
start | |
0:00:14.463224 | |
start | |
0:00:16.267539 | |
start | |
0:00:14.508425 | |
$ | |
$ | |
$ cat test2.py | |
#!/usr/bin/env python3 | |
import datetime | |
import random | |
dividends = [] | |
divisors = [] | |
for i in range(1000 * 1000): | |
dividends.append(random.randint(1,1000000000)) | |
divisors.append(random.randint(1,1000000000)) | |
start_time = datetime.datetime.now() | |
print('start') | |
for i in range(100): | |
for j in range(len(dividends)): | |
dividends[j] = int(dividends[j] / divisors[j]) | |
print(datetime.datetime.now() - start_time) | |
$ for i in {1..5}; do ./test2.py; done | |
start | |
0:00:29.424211 | |
start | |
0:00:29.924678 | |
start | |
0:00:29.382029 | |
start | |
0:00:29.160739 | |
start | |
0:00:31.114885 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment