Register to reply

How to calculate program execution time?

by CodeMonkey
Tags: execution, program, time
Share this thread:
Nov13-07, 09:44 PM
P: 11
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?
Phys.Org News Partner Science news on
Final pieces to the circadian clock puzzle found
A spray-on light show on four wheels: Darkside Scientific
How an ancient vertebrate uses familiar tools to build a strange-looking head
Nov13-07, 10:29 PM
HW Helper
P: 7,169
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.
Nov13-07, 10:52 PM
PF Gold
ranger's Avatar
P: 1,684
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:

Nov13-07, 11:53 PM
P: 11
How to calculate program execution time?

Sorry I shouldve added that I'm new to this. Can you please tell me which namespace, class and methods to use in Csharp?
jim mcnamara
Nov14-07, 05:32 AM
Sci Advisor
PF Gold
P: 1,386
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'

Register to reply

Related Discussions
Calculate the time constant (RC circuit) Introductory Physics Homework 16
How to calculate inertia from deceleration time Introductory Physics Homework 0
Calculate time constant from the slope of dimensionless temperature vs time graph. Introductory Physics Homework 2
C - execution trouble Computing & Technology 6
How to calculate the time taken for the sun to cool down? Astronomy & Astrophysics 7