在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
生词解释:Diagnostics[,daɪəg'nɑstɪks] n.诊断学 using System.Diagnostics; Stopwatch sw = new Stopwatch (); sw.Start (); string str = "a"; for (var i = 0; i < 10000; i++) { str += "b"; } sw.Stop (); Console.WriteLine (sw.Elapsed); // 输出 从 Start() 到 Stop() 之间经过时间。(单位:秒)
还一个也很方便的。
long startTime = DateTime.Now.Millisecond; string str = "abc"; for (var i = 0; i < 1000; i++) { str += "abc"; } long endTime = DateTime.Now.Millisecond; Console.Write(str); Console.WriteLine("str 拼接1000次,用时:{0}毫秒。", endTime - startTime); startTime = DateTime.Now.Millisecond; str = ""; for (var i = 0; i < 100; i++) { str += 'a'; } endTime = DateTime.Now.Millisecond; Console.Write(str); Console.WriteLine("str 拼接100次,用时:{0}毫秒。", endTime - startTime);
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论