CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: program timing?

  1. #1
    Join Date
    May 1999
    Posts
    2

    program timing?

    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

  2. #2
    Join Date
    May 1999
    Posts
    3

    Re: program timing?

    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;





  3. #3
    Join Date
    May 1999
    Posts
    2

    Re: program timing?

    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

  4. #4
    Join Date
    May 1999
    Posts
    19

    Re: program timing?

    See the discussion on CPU Time on 95/98/NT, last post on 30/4/99.

    [email protected]
    B'lore
    India.


  5. #5
    Join Date
    May 1999
    Posts
    11

    Re: program timing?

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured