Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdsharpe committed Dec 22, 2023
1 parent 6f6a0f1 commit 958dd2b
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions aerosandbox/tools/code_benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,25 @@ class Timer(object):
Results are printed to stdout. You can access the runtime (in seconds) directly with:
with Timer("My timer") as t:
# Do stuff
print(t.runtime)
>>> with Timer("My timer") as t:
>>> # Do stuff
>>> print(t.runtime) # You can dynamically access the runtime of any completed Timer, if desired
Nested timers are also supported. For example, this code:
>>> with Timer("a"):
>>> with Timer("b"):
>>> with Timer("c"):
>>> f()
yields the following console output:
[a] Timing...
[b] Timing...
[c] Timing...
[c] Elapsed: 100 msec
[b] Elapsed: 100 msec
[a] Elapsed: 100 msec
"""
number_running: int = 0 # The number of Timers currently running

Expand Down

0 comments on commit 958dd2b

Please sign in to comment.