import stopwatch
from os import sleep
var c: clock
# example without using the bench abstraction
c.start()
sleep(1)
c.stop()
echo ($(c.clockStop - c.clockStart) & "ns") # in nanoseconds
echo c.seconds, "s"
# another example using bench, a template that generates the clock.start/stop code as shown in the first example
var c0, c1, c2: clock
bench(c):
bench(c0):
sleep(100)
bench(c1):
sleep(50)
bench(c2):
for i in 0..<2:
sleep(1)
echo "bench 0): ", c0.seconds, "s"
echo "bench 1): ", c1.seconds, "s"
echo "bench 2): ", c2.seconds, "s"
echo "total: ", c.seconds, "s"
-
Notifications
You must be signed in to change notification settings - Fork 1
A simple benchmarking/timer library based on nim's lib/system/timers.nim
License
eagle-provision/Timer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A simple benchmarking/timer library based on nim's lib/system/timers.nim
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published