Click to See Complete Forum and Search --> : program timing?
csantosh
May 7th, 1999, 01:13 AM
Hi, i have written a time-critical program in c++, and now i want to measure
how much time is taken by the cpu to run that program. I use visual c++ on win95/NT. i tried with the profiler available in vc++6, but it only gives the elapsed time. i want how much time cpu spent processing the program, (some things like "time" command in unix).
does anybody know of any program like "time on unix", on win95/NT.
Santosh Cheler
Shanker
May 7th, 1999, 01:30 AM
Hmmm, I'm not sure, but try the clock functions available..something like this:
#include <time.h>
clock_t begin;
clock_t end;
begin = clock();
.
.
// Some Processing
.
.
end = clock();
cout << "Elapsed Time" << (end-start) / CLK_TCK;
csantosh
May 7th, 1999, 02:17 AM
no, the problem with this solution is, u dont know how much time is spent in ur program.
it includes the time spent by other programs also that are running in background, like services.
what is needed is a program that runs at operating system level, so that it can record the time
while scheduling/dispatching.
Santosh Cheler
Ashley Antony
May 10th, 1999, 02:20 AM
See the discussion on CPU Time on 95/98/NT, last post on 30/4/99.
Ashley.Antony@in.bosch.com
B'lore
India.
Surinder
May 10th, 1999, 04:09 AM
Create the thread function for ur process. Just count no. of clocks spend during ur thread execution.
Algo..
global or static variable Total_clocks
Thread()
{
start_thread=clock();
....
...
....
end_thread=clock();
Total_clock+=(end_thread-start_thread);
}
The time spend by ur process will be executed in a thread & computing the time spend in a thread will give u the time u want as given by time() in unix.
If u have some thing on VXDs programming in windows please reply me.
surinder
ICQ #3760 3760
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.