评论

收藏

[C++] [C#]记录程序耗时的方法【转发】

编程语言 编程语言 发布于:2021-08-10 11:37 | 阅读数:273 | 评论:0

System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
// Here: 需要计算耗时的过程/方法
stopwatch.Stop();
stopwatch.Elapsed.TotalSeconds //这里是输出的总运行秒数,精确到毫秒的
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
byte[] a = System.IO.File.ReadAllBytes("x:\\新建文本文档.txt");
textBox2.AppendText("\r\n载入文件 总长{1} 耗时{0}秒  ".FormatWith(stopwatch.Elapsed.TotalSeconds, a.Length));
stopwatch.Reset(); stopwatch.Start();
byte[] b = LC.Fun.Hash.AES_Encrypt(a, "#JBP@Bb$DJGJ#1A!2");
textBox2.AppendText("\r\n加密完成 总长{1} 耗时{0}秒".FormatWith(stopwatch.Elapsed.TotalSeconds, b.Length));
stopwatch.Reset(); stopwatch.Start();
byte[] c = LC.Fun.Hash.AES_Decrypt(b, "#JBP@Bb$DJGJ#1A!2");
textBox2.AppendText("\r\n解密完成 总长{1} 耗时{0}秒".FormatWith(stopwatch.Elapsed.TotalSeconds, c.Length));
stopwatch.Stop();
学习交流群:364976091


关注下面的标签,发现更多相似文章