up vote 2 down vote favorite
share [g+] share [fb]

What is the windows analog to unix time command?

link|improve this question
feedback

migrated from stackoverflow.com Dec 28 '09 at 5:11

This question came from our site for professional and enthusiast programmers.

3 Answers

This is a duplicate of an older question on stackoverflow - see there for many answers :)

link|improve this answer
feedback

You can use timeit.exe from the Windows Server 2003 Resource Kit.

Syntax:

timeit [-f FileName] [-a] [-c] [-i] [-d] [-s] [-t] [-k KeyName | -r KeyName] 
[-m Mask] [Command]

-f FileName  
Specifies the name of the database file where TimeIt keeps a history of 
previous timings. The default file name is .\Timeit.dat

-k KeyName
Specifies the keyname to use for this timing run.

-r KeyName
Specifies the key name to remove from the database. If the key name is 
followed by a comma and a number, the slowest time (positive number) or
the fastest time (negative number) for that key name will be removed.

-a
Specifies that TimeIt should display average of all timings for the 
specified key name.

-i
Ignores nonzero return codes from the program run by TimeIt.

-d
Shows detail for average.

-s
Suppresses systemwide counters.

-t
Specifies tabular output.

-c
Forces a re-sort of the database.

-m Mask
Specifies the processor affinity mask.

Command
Specifies the command to time.
link|improve this answer
But the unix 'time' command doesn't return the current epoch time, so that's not relevant. 'time' runs the command you put on the commandline after it, then tells you how much real/user/system time the command took. unixhelp.ed.ac.uk/CGI/man-cgi?time has more details. – James Polley Dec 28 '09 at 6:01
Ah. I read the question incorrectly. – John T Dec 28 '09 at 6:15
** Sigh ** seems my answer was mentioned on the SO page you linked to. – John T Dec 28 '09 at 6:22
:) Easy to be confused, especially when time on DOS/Windows is equivalent to date on *nix – James Polley Dec 28 '09 at 6:24
Oh I'm very familiar with both. I just thought of the windows clock when it said Windows analog, as analog is a type of clock. The other meaning of analog wasn't on my mind :P – John T Dec 28 '09 at 6:33
feedback

Write a C program using the GetProcessTimes function, you could find its documentation in: http://msdn.microsoft.com/en-us/library/ms683223%28VS.85%29.aspx.

In the examples of the book "Windows System Programming" comes a program that use that function to retrieve exactly what you need(Elapsed, Kernel, User times). The program is call "timep.exe" and it can be found in the runX subdirectories (the X comes from the version of Visual Studio used in the compilation) inside the zipped examples archive. Here is the author page from where you could download that archive http://www.jmhartsoftware.com/, of course the source code is also there so you could see exactly how timep.exe works.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown