Sam*_*abu 4 msbuild powershell powershell-2.0 msbuild-4.0
我在msbuild中构建脚本,将由powershell调用.
构建日志文件看起来像这样.
生成于2011年12月19日下午2:01:54开始.
构建成功.0警告0错误
时间流逝00:00:00.28
在起始点,它将指定构建执行启动的时间,并指示时间已过去.
我想使用powershell或msbuild找到执行时间.如何添加所有时间过去的值或找到上次构建开始发生与第一次构建发生之间的差异?
因为它在日志文件中,我不知道如何检索和测量.
小智 6
请注意,如果使用Measure-Command {},它将使用构建的控制台输出.所以任何输出都会消失.
一种不那么干扰的方法是简单地减去Get-Date值.例如,这是您的build.ps1脚本:
$before = Get-Date
<your build command line>
$after = Get-Date
$time = $after - $before
$buildTime = "`nBuild finished in ";
if ($time.Minutes -gt 0)
{
$buildTime += "{0} minute(s) " -f $time.Minutes;
}
$buildTime += "{0} second(s)" -f $time.Seconds;
Run Code Online (Sandbox Code Playgroud)
用Measure-Commmand
看到的是多久你的构建过程.这是一个例子:
Measure-Command { ./build.ps1 }
Run Code Online (Sandbox Code Playgroud)
我机器上的输出是:
PS D:\> Measure-Command { ./build.ps1 }
Days : 0
Hours : 0
Minutes : 0
Seconds : 6
Milliseconds : 443
Ticks : 64439301
TotalDays : 7.45825243055556E-05
TotalHours : 0.00178998058333333
TotalMinutes : 0.107398835
TotalSeconds : 6.4439301
TotalMilliseconds : 6443.9301
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1435 次 |
最近记录: |