Should I Stop Stopwatch at the end of the method?

后端 未结 4 2033
春和景丽
春和景丽 2021-02-06 20:23

Let\'s imagine we have simple measurements using Stopwatch

public void DoWork()
{
    var timer = Stopwatch.StartNew();
    // some hard work
    Lo         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 20:44

    No, you don't need to stop it. Stop() just stops tracking elapsed time. It does not free up any resources.

提交回复
热议问题