CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    3

    PERF_ELAPSED_TIME Counter

    I've created my own PerfMon object and counters for my server application.
    I'm able to get PERF_COUNTER_RAWCOUNT and PERF_COUNTER_COUNTER counters
    working, but I can't seem to get the PERF_ELAPSED_TIME counters working.
    PERF_ELAPSED_TIME is defined in WINPERF.H as:

    // The data collected in this counter is actually the start time of the
    // item being measured. For display, this data is subtracted from the
    // sample time to yield the elapsed time as the difference between the two.
    // In the definition below, the PerfTime field of the Object contains
    // the sample time as indicated by the PERF_OBJECT_TIMER bit and the
    // difference is scaled by the PerfFreq of the Object to convert the time
    // units into seconds.
    #define PERF_ELAPSED_TIME \
    (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_ELAPSED |\
    PERF_OBJECT_TIMER | PERF_DISPLAY_SECONDS)



    In my app I value the counter by:

    time_t StartTime;
    g_PrfData.GetCtr32(ELAPSED_TIME) = time(&StartTime);



    This was just a guess, I have no idea what kind of data type the "start
    time" in the comment above expects.

    Any ideas?

    Thanks,

    -- Pat
    mailto: [email protected]

  2. #2
    Guest

    Re: PERF_ELAPSED_TIME Counter

    Try this :
    FILETIME ta,tb,tc,td;
    GetProcessTimes(GetCurrentProcess(),(LPFILETIME)&ta,(LPFILETIME)&tb,
    (LPFILETIME)&tc,(LPFILETIME)&td);
    g_PrfData.GetCtr32 = ta.dwHighDateTime * 4294967296e+0 + ta.dwLowDateTime;

    Remember : PERF_ELAPSED_TIME is a PERF_SIZE_LARGE counter(LONGLONG, GetCtr32 ?).

    The monitor compute this counter making :
    float fTime = (float)((object.PerfTime.u.HighPart * 4294967296e+0 +
    object.PerfTime.u.LowPart) - GetCtr32) /
    (object.PerfFreq.u.HighPart * 4294967296e+0 +
    object.PerfFreq.LowPart);




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