-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.py
More file actions
35 lines (28 loc) · 784 Bytes
/
launch.py
File metadata and controls
35 lines (28 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python3.8
from sys import argv
from time import time_ns
from fib import fib
def run_fib(i):
race_one_start = time_ns()
race_one_results = fib(i)
race_one_finish = time_ns()
time_one = (race_one_finish - race_one_start) / 1e9
print(f">>> fib({i})")
print(f"{race_one_results}")
print(f" info: {fib.__doc__}")
print(f" time: {time_one} seconds")
print()
def main(i):
'''Race between fib functions'''
run_fib(i)
if (__name__ == '__main__'):
usage ='''usage: launch (number of iterations between 0 and 498)'''
argc = len(argv)
if (argc >= 2):
cycles = int(argv[1])
if isinstance(cycles, int):
main(cycles)
else:
print(usage)
else:
print(usage)