1

I'm writing a program that performs certain optimizations on an executable file and am looking for a way to measure the time the executable took to run.

I've been using a script that measures the start time and end time, but this doesn't take into account that the process might not be running all the time (due to OS resource allocation).

Will the PowerShell command 'Measure-Command' give me a more precise response? And will 'Time' do the same on Linux?

If not, how should I go about doing so? (A command line solution is preferable.)

2
  • I don't know if it can be done outside of the program itself. What language is the program being written in? Aug 25, 2013 at 13:51
  • @ScottChamberlain Java. I looked it up, but it seems that I can only accomplish this through java if I set it up in an outside environment (Like Google Caliper), and only for benchmarking purposes, while I need it for my program behavior.
    – Ysch
    Aug 25, 2013 at 16:12

2 Answers 2

0

I can't speak as to the Windows command, but yes, the *nix time will give you a more precise response:

$ time du -sch /usr/local/
147M  /usr/local/
147M  total

real    0m2.977s
user    0m0.008s
sys     0m0.076s

According to man time it can display (among many other things):

    E      Elapsed real (wall clock) time used by
           the process, in
           [hours:]minutes:seconds.
    P      Percentage of the CPU that this job
           got.  This is just user + system times
           divided by the total running time.  It
           also prints a percentage sign.
    S      Total number of CPU-seconds used by the
           system on behalf of the process (in
           kernel mode), in seconds.
    U      Total number of CPU-seconds that the
           process used directly (in user mode),
           in seconds.
    e      Elapsed real (wall clock) time used by
           the process, in seconds.
0

In PowerShell, you can use Get-Process:

Get-Process | select starttime

You must log in to answer this question.

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