Skip to content

A simple benchmarking/timer library based on nim's lib/system/timers.nim

License

Notifications You must be signed in to change notification settings

eagle-provision/Timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stopwatch

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"

About

A simple benchmarking/timer library based on nim's lib/system/timers.nim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages