但是这里的答案错了我用过的程序 这里是C#程序What is the average execution time of the function?What I have tried:I have used the Average Execution formula1035+1015+1020+1025+1010 / 5 = 1020But the Answer is Wrong here The program what i have usedHere is the C# programStopwatch sw = newStopwatch();sw.Start();f();sw.Stop();Console.WriteLine(sw.Elapsed);推荐答案使用 .TotalMilliseconds 。如果你想要秒数,则除以1000(1000毫秒= 1秒)...Use .TotalMilliseconds. Divide by 1000 (1000 milliseconds = 1 second) if you want number of seconds...Stopwatch sw = new Stopwatch();sw.Start();f();sw.Stop();Console.WriteLine( {sw.TotalMilliseconds / 1000 }秒); 这篇关于在C#中测量函数的执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 22:37