Under the Hood of Stopwatch

Introduction

As all developers, I often need to measure execution time of my own (and not only my own) code. When I was a beginning programmer, I used the DateTime structure for his purpose. Time have passed and I learned about the Stopwatch class and began using it extensively. I think most of you had similar experience. It’s not like I didn’t wonder about how Stopwatch works, at that time, it was simply enough for me to know that Stopwatch measures the elapsed time more precise than DateTime. Now the time has come to explain to myself as well as to the readers how the Stopwatch class actually works and clarify its pros and cons in comparison with DateTIme.
(more…)