How long does my code take to run?

后端 未结 6 1606
轮回少年
轮回少年 2021-02-05 22:43

How can I find out how much time my C# code takes to run?

6条回答
  •  無奈伤痛
    2021-02-05 23:11

    If you want simple, just put an N-iteration loop around it and use StopWatch (or just a wristwatch) and divide by N. For example, if you want microseconds, let N = 1000000. If you're worried about the overhead of the loop, just unroll it by a factor of 10.

提交回复
热议问题