Skip to content

Commit

Permalink
CLI control over number of iterations to check
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviernogueira committed Dec 14, 2023
1 parent c94a2e4 commit 9b97882
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions examples/dev_sandbox/prof.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""A script to allow for debugging of the TSM module."""
import clearwater_modules
import time
import sys

def main():
def main(iters: int):
ti = time.time()
# define starting state values
state_i = {
Expand All @@ -18,9 +19,20 @@ def main():
)
print(tsm.static_variable_values)
t2 = time.time()
for _ in range(1000):
for _ in range(iters):
tsm.increment_timestep()
print(f'Increment timestep speed (average of 100): {(time.time() - t2) / 100}')
print(f'Increment timestep speed (average of {iters}): {(time.time() - t2) / 100}')
print(f'Run time: {time.time() - ti}')

if __name__ == '__main__':
main()
if len(sys.argv) > 1:
try:
iters = int(sys.argv[1])
print(f'Running {iters} iterations.')
except ValueError:
raise ValueError('Argument must be an integer # of iterations.')
else:
print('No argument given, defaulting to 100 iteration.')
iters = 100

main(iters=iters)

0 comments on commit 9b97882

Please sign in to comment.