How do I measure task duration?

Jun 5, 2009 at 6:18 PM

I plan on using something like that (from documentation):

<MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(Start)" Format="Total">

But I don't know how to set $(Start) to current date time in the begining of the task execution.

 

Coordinator
Jun 5, 2009 at 6:39 PM

You can get out the box task info by running with the additional command line parameter /clp:PerformanceSummary

If you want to time a section, use this:

    <Target Name="Default">
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="Get" Format="dd MMM yy HH:mm:ss">
            <Output TaskParameter="Result" PropertyName="MyStartTime"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="I'm sleeping..."/>
        <MSBuild.ExtensionPack.Framework.Thread TaskAction="Sleep" Timeout="2000"/>
        <Message Text="Sleep Over!"/>
        <MSBuild.ExtensionPack.Framework.DateAndTime TaskAction="GetElapsed" Start="$(MyStartTime)" Format="Seconds">
            <Output TaskParameter="Result" PropertyName="DTResult"/>
        </MSBuild.ExtensionPack.Framework.DateAndTime>
        <Message Text="Slept For: $(DTResult)"/>
    </Target>

Mike

Jun 5, 2009 at 7:04 PM

Thanks,

That's exactly what I need.

I think it is a common scenario, so documention could benefit from this example.

Coordinator
Jun 5, 2009 at 7:27 PM

No problem. I've updated the sample. Will ship with 3.5.3.0 on Sunday / Monday.