To help those searching for a modern solution to this question, and use .NET, give BenchmarkDotNet a try.