How to calculate program execution time?

  1. I'm using VS and coding in Java, C++ and C#. What are the methods to use to display the time it takes for the program to execute in ms?
  2. jcsd
  3. rcgldr

    rcgldr 7,692
    Homework Helper

    I've used the following:

    Highest resolution timer, but includes overhead from other tasks. Still I found it to be the best. Using SetThreadPriority() to bump up priority should reduce overhead from other tasks.

    Supposed to exclude overhead from other processes, but seems to include interrupt overhead. timeBeginPeriod() (requires a later timeEndPeriod()) can be used increase the tick rate, but this also seems to increase the reported time, indicating that interrupt overhead is included in the process times.

    A more generic time call. On Windows XP, reports time in milliseconds, but appears to be based on a 64hz ticker.
  4. ranger

    ranger 1,663
    Gold Member

    It is quite easy to do it on a UNIX based system. You can make use of the time command. I've found a very interesting paper that talks about program execution time:
  5. Sorry I shouldve added that I'm new to this. Can you please tell me which namespace, class and methods to use in Csharp?
  6. jim mcnamara

    jim mcnamara 1,565
    Science Advisor
    Gold Member

    If this is a critical app, consider profiling. There are profilers for all of .NET.

    Profilers time each function in your code so you can see where you have problems. There are java profilers as well. Some are free or have trial periods.

    google for '.net profiler'
Know someone interested in this topic? Share this thead via email, Google+, Twitter, or Facebook

Have something to add?