【发布时间】:2014-11-01 15:08:53
【问题描述】:
如何计算处理时间,例如将文件从 1 个文件夹复制到另一个文件夹? 打开网络浏览器或计算器。该命令由批处理文件提供给 c#,c#first 读取此文件执行它并告诉我每个进程的时间跨度。
【问题讨论】:
-
为什么不在每个进程之前和之后添加一个 DateTime.Now 并减去它们?
标签: c#
如何计算处理时间,例如将文件从 1 个文件夹复制到另一个文件夹? 打开网络浏览器或计算器。该命令由批处理文件提供给 c#,c#first 读取此文件执行它并告诉我每个进程的时间跨度。
【问题讨论】:
标签: c#
秒表最适合计算经过的时间
stopwatch sw = new stopwatch;
sw.Start();
// do something here that you want to measure
sw.Stop();
// Get the elapsed time as a TimeSpan
TimeSpan ts = sw.Elapsed;
// Format and display the TimeSpan
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("That took: {0}", elapsedTime);
【讨论】: