How to calculate program execution time?


by CodeMonkey
Tags: execution, program, time
CodeMonkey
CodeMonkey is offline
#1
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 Phys.org
SensaBubble: It's a bubble, but not as we know it (w/ video)
The hemihelix: Scientists discover a new shape using rubber bands (w/ video)
Microbes provide insights into evolution of human language
rcgldr
rcgldr is online now
#2
Nov13-07, 10:29 PM
HW Helper
P: 6,931
I've used the following:

QueryPerformanceCounter()
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.

GetProcessTimes()
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.

clock()
A more generic time call. On Windows XP, reports time in milliseconds, but appears to be based on a 64hz ticker.
ranger
ranger is offline
#3
Nov13-07, 10:52 PM
PF Gold
ranger's Avatar
P: 1,686
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:
http://csapp.cs.cmu.edu/public/ch9-preview.pdf

CodeMonkey
CodeMonkey is offline
#4
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
jim mcnamara is offline
#5
Nov14-07, 05:32 AM
Sci Advisor
PF Gold
P: 1,355
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? Astrophysics 7