A Stopwatch for Nim

As I mentioned in the previous post, I've been playing around with the Nim language for a little less than a month now.  So far I really like it and have used it for messing with computer graphics.  I like to record how long things take to compute so I set out to look for a Timer of sorts.  I was a little surprised to find out that it didn't have a built-in timing/benchmarking mechanism (like C# has with the Stopwatch class).  There was a package made available by rbmz under the name of stopwatch that did some very basic stuff for me, but I was still unsatisfied.  So I decided to do a fork of it and made all of the changes that I wanted.

There were two main things that I changed.  the clock object was renamed to Stopwatch, and the Stopwatch can now record multiple laps.  What I mean by "laps," is that you can now start and stop the Stopwatch multiple times and it will remember those timings for you.  Some other minor additions include methods to convert nanoseconds over to milli- and microseconds.  To see everything that was added check the source code here, everything should be documented and easy to follow (there isn't much).

If you want to grab the package, it's up on nimble as stopwatch.  Yes, one of the maintainers was nice enough to let me hijack the original package name.  Here are some code samples (ripped from the README) that show you how to use this package:



You can find the repo here.  If you have any requests or find any bugs please tell me.