Check that Source code you get from the Internet.

I was looking at a page that did some timings of an API we use here at work and noticed that it was showing ms (milliseconds) rather than s (seconds).   It reminded me a bit of Verizon math as it was fairly obvious that these timings were completing in about 6 seconds and not 6 milliseconds.  I sent an email to my colleague who wrote the page and he indicated he had used it from a comment on a post at Scott Hanselman's site.  I noticed that the code there was using the kernel methods QueryPerformanceCounter and QueryPerformanceFrequency so I looked them up in MSDN and found that the QueryPerformanceFrequency was a count per second and not count per millisecond and that the code in the comment was wrong (formatted wrong).  Scott had long since closed the comments on this post and since I didn't have a way of pointing out the error at that source and with Scott's encouragement, I am writing this blog post.

Using code found on the internet is a great way to save time but you should understand what you are using and how it works.  Ultimately you are responsible for the function of the code when you send it off to your colleagues or boss.  It also turns out that this timing could more easily be done with the System.Diagnostics.Stopwatch class which uses the same kernel methods without cluttering your user code with the extern calls.  It also provides the results in a Timespan which makes it more clear just how long the results of your test took.