8

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

5
  • What feature of /usr/bin/time are you looking for on Windows, specifically? Aug 28, 2009 at 0:49
  • The ability to time my programs of course.
    – unknown
    Aug 28, 2009 at 0:53
  • 4
    Your question assumes that people know what time actually does on Linux. Someone may not use Linux, but may know a Windows Alternative to what you're looking for (which is the ultimate goal of your question) - it would be helpful for those people to state what you're looking to achieve. Aug 28, 2009 at 1:40
  • I agree with EvilChookie. +1 now that I understand what you want. Aug 28, 2009 at 3:15
  • Please see my answer for a link to timethis.exe which does what you want and is available as an approx 116K download. Aug 28, 2009 at 3:21

7 Answers 7

2

Use timethis from the Win2K resource kit.

3
  • i don't like how it has to clear your terminal when you use it.
    – unknown
    Sep 3, 2009 at 1:25
  • @unknown I have never observed timethis clearing the terminal. Sep 24, 2009 at 7:59
  • link dead...... Jul 1 at 12:32
3

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
2

If you want time to use it as a benchmark utility, the Windows 2003 Resource Kit has Timeit.exe which does the same.

4
  • Cool, can I get it without getting everything else there?
    – unknown
    Aug 28, 2009 at 0:44
  • Unfortunately that seems to be the only download Microsoft provides. But there are a lot of useful tools in there which I have renamed to their UNIX equivalent and dropped into my System32 folder for use from the command line. You can simply delete the ones which you don't want.
    – John T
    Aug 28, 2009 at 0:50
  • John T, congrats on being first to 10k! Enjoy reading your posts... Don't know how you find the time as every time I am about to submit, you seem to have the same / slightly better answer! Here's to the next 10k!- Delete this after you have read it as there is no private message feature! (or write another commend then il delete it) Aug 28, 2009 at 1:59
  • @Wil, thanks! I cannot delete it and there is no need to. Comments are exactly that, comments. Good ones are rather appreciated :)
    – John T
    Aug 28, 2009 at 5:18
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.

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.

1

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.

2
  • 1
    I don't think he's looking for uptime. time on linux measures the real and cpu time for a process. Aug 28, 2009 at 0:38
  • @prestomation: Ah. Edited, adding something else that would help. Aug 28, 2009 at 0:48
0

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 must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .