You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varsw=Stopwatch.StartNew()// do your wok
sw.Stop();Console.WriteLine($"Elapsed time: {sw.Elapsed.Microseconds} ms");
从性能角度来看,这段代码的问题是 Stopwatch 是要给 class 类型,每次都会在堆上分配一个对象,增加垃圾回收的负担。所以 Stopwatch 类提供了一个更加高效的实现
longstartTime=Stopwatch.GetTimestamp();// do you workvarelapsedTime=Stopwatch.GetElapsedTime(startTime);Console.WriteLine($"Elapsed time: {elapsedTime.Microseconds} ms");
https://www.youtube.com/watch?v=Lvdyi5DWNm4&ab_channel=NickChapsas
The text was updated successfully, but these errors were encountered: