Is there a built-in way to measure execution time of a command on the Windows command line?
If you are using Windows 2003 (note that windows server 2008 and later are not supported) you can use The Windows Server 2003 Resource Kit, which contains timeit.exe that displays detailed execution stats. Here is an example, timing the command "timeit -?":
C:>timeit timeit -? Invalid switch -? Usage: TIMEIT [-f filename] [-a] [-c] [-i] [-d] [-s] [-t] [-k keyname | -r keyname] [-m mask] [commandline...] where: -f specifies the name of the database file where TIMEIT keeps a history of previous timings. Default is .timeit.dat -k specifies the keyname to use for this timing run -r specifies the keyname to remove from the database. If keyname is followed by a comma and a number then it will remove the slowest (positive number) or fastest (negative) times for that keyname. -a specifies that timeit should display average of all timings for the specified key. -i specifies to ignore non-zero return codes from program -d specifies to show detail for average -s specifies to suppress system wide counters -t specifies to tabular output -c specifies to force a resort of the data base -m specifies the processor affinity mask Version Number: Windows NT 5.2 (Build 3790) Exit Time: 7:38 am, Wednesday, April 15 2009 Elapsed Time: 0:00:00.000 Process Time: 0:00:00.015 System Calls: 731 Context Switches: 299 Page Faults: 515 Bytes Read: 0 Bytes Written: 0 Bytes Other: 298
You can get TimeIt in the Windows 2003 Resource Kit. It's not available for direct download from the Microsoft Download Center, but one can still get it from the arhive.org - Windows Server 2003 Resource Kit Tools.
TASKLIST does not set errorlevel.
echo off tasklist /fi "imagename eq notepad.exe" |find ":" > nul if errorlevel 1 taskkill /f /im "notepad.exe" exit
should do the job, since ":" should appear in
TASKLIST output only if the task is NOT found, hence
FIND will set the errorlevel to
not found and
taskkill /f /im "notepad.exe"
will kill a notepad task if it exists - it can do nothing if no notepad task exists, so you don't really need to test - unless there's something else you want to do...like perhaps
echo off tasklist /fi "imagename eq notepad.exe" |find ":" > nul if errorlevel 1 taskkill /f /im "notepad.exe"&exit
which would appear to do as you ask - kill the notepad process if it exists, then exit - otherwise continue with the batch
Using Rails 3, you're looking for DateTime.change()
dt = DateTime.now => Mon, 20 Dec 2010 18:59:43 +0100 dt = dt.change(:offset => "+0000") => Mon, 20 Dec 2010 18:59:43 +0000
Thanks to an answer to Stack Overflow quesion Creating a file name as a timestamp in a batch job, I found that it was a space terminating the filename.
I think it should be sufficient to call the
UIElement.Measure(Size) method and subsequently check the
UIElement.DesiredSize property. For more information, check the provided MSDN links.