Last active
November 7, 2022 07:58
-
-
Save dichharai/4b431a7e491720b83cd8e38101604ae6 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
from threading import Thread | |
from time import perf_counter | |
def sum_up_to(start: int, end: int): | |
total = 0 | |
print('start...') | |
for i in range(start, end): | |
total += i | |
print('end...') | |
print(f'sum from {start}..{end} is {total}.') | |
if __name__ == "__main__": | |
start = perf_counter() | |
t1 = Thread(target=sum_up_to, args=(1, 10_000)) | |
t1.start() | |
t1.join() | |
print(f'Took {perf_counter() - start:.6f} seconds.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment