Measure code speed in .net in milliseconds

后端 未结 4 486
灰色年华
灰色年华 2021-02-03 11:09

I want to get the maximum count I have to execute a loop for it to take x milliseconds to finish.

For eg.

int GetIterationsForExecutionTime(int ms)
{
            


        
4条回答
  •  滥情空心
    2021-02-03 11:57

    var sw = Stopwatch.StartNew();
    ...
    long  elapsedMilliseconds = sw.ElapsedMilliseconds;
    

提交回复
热议问题