Search code examples
c#algorithmperformance-testing

How to measure performance of a C# algorithm developed on a VirtualBox running on MacBook?


I am writing a C# algorithm for a personal project and would like to test the performance of the algorithm. Like how much it takes for a million iterations e.t.c. I am programming in visual studio 2017 running in a VirtualBox on a MacBook Pro.

I am pretty sure if I do performance testing from within the VirtualBox the numbers would never be right.

  1. Is there a way to test the algorithm performance directly on Mac?
  2. Or some service or tool that I can use to do it?
  3. Are there any benchmarking tools available for benchmarking performance of .net algorithms that will tell me how good an algorithm is?

I don't have access to a windows machine.. hence asking..

I also thought of creating a windows AWS instance and testing performance there but not sure how accurate that would be.. please advise..


Solution

  • Benchmarking code in a VM is absolutely fine because benchmarks are a relative result. You benchmark code, make code improvements and benchmark it again to see if there are performance improvements (or if you have made it worse). If you want to benchmark your algorithm against other implementations, you just need to benchmark those in the same VM.

    Benchmarks can only tell you that one thing is better than another, not whether one thing is good.

    That being said, you don't need to use the VM at all. .Net Core works on macOS and there are good benchmarking libraries for .Net Core.