8

Is there a clean Windows port / version of the /usr/bin/time command in Linux (program to time the execution of a process)?

phuclv
  • 30,396
  • 15
  • 136
  • 260
unknown
  • 277

5 Answers5

2

I have created a simple Windows program called timemem.exe that behaves similarly to /usr/bin/time on Linux/Mac OS X, and will show similar statistics, such as elapsed time, user and kernel CPU time, and maximum working set size in memory used by another Win32 process. See:

http://homepage.mac.com/jafingerhut/files/code/code.html

1

A bit late to the party, but I was searching for a Windows version of /usr/bin/time. Could not find anything, so I wrote a clone:

https://github.com/cbielow/wintime

It can measure

  • execution time of a program
  • RAM usage (maximum)
  • page faults etc...

including logging to a CSV file. Precompiled binaries are available. Just download and run it.

cbielow
  • 131
1

PowerShell already has the built-in capability to measure runtime with the cmdlet Measure-Command

Measure-Command { Get-EventLog "windows powershell" }

Of course it can also be called from cmd or any applications

powershell -C "Measure-Command { sleep 2 }"

You can also get the time unit you want directly:

PS C:\> (Measure-Command { sleep 0.01 }).TotalNanoseconds
75338500
PS C:\> (Measure-Command { sleep 0.1 }).TotalMicroseconds
171909.5
PS C:\> (Measure-Command { sleep 0.3 }).TotalMilliseconds
344.8681
PS C:\> (Measure-Command { sleep 3.5 }).TotalSeconds
3.5562432
phuclv
  • 30,396
  • 15
  • 136
  • 260
1

You could always install Cygwin which will give you the UNIX time command. It is pretty useful to have Cygwin installed anyway.

By you asking for a clean port or version, I don't think Cygwin would be acceptable. The only thing I have found is this for custom code to compile on Windows. As I didn't find any links where this has been set up as the time command, I don't know that you could get this to work unless you wanted to program it yourself.

0

On my Mac, /usr/bin/time returns the system uptime.

On a Windows computer, you can use the following to return the uptime: net stats server

The 'Statistics Since' will give you the time the computer was last powered up. There's also a server tool - uptime.exe

There's more information at the Microsoft Support Site.

Of course, if you're not looking to find the uptime of a computer, I'm way off the mark. If you're not looking for uptime, what are you looking to achieve?

Edit: If you're looking for CPU time as suggested in a comment, you can use the tasklist command. Punch in tasklist /? at a command prompt and see the info about it.

phuclv
  • 30,396
  • 15
  • 136
  • 260
EvilChookie
  • 4,577