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, "#[email protected]$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, "#[email protected]$DJGJ#1A!2"); textBox2.AppendText("\r\n解密完成 总长{1} 耗时{0}秒".FormatWith(stopwatch.Elapsed.TotalSeconds, c.Length)); stopwatch.Stop();
时间: 2024-10-07 16:50:27