Created
September 20, 2022 00:27
-
-
Save weirddan455/b90b6496afa0811e05e619d823383ecf 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
from time import perf_counter_ns | |
array_size = 1000000 | |
array = [] | |
with open("unsorted.txt") as unsorted: | |
for i in range(array_size): | |
array.append(int(unsorted.readline())) | |
start = perf_counter_ns() | |
array.sort() | |
end = perf_counter_ns() | |
with open("sorted.txt", 'w') as sorted: | |
for i in range(array_size): | |
sorted.write(str(array[i])) | |
sorted.write('\n') | |
duration = (end - start) / 1000000.0 | |
print("sort took " + str(duration) + "ms") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment