Announcement

Collapse
No announcement yet.

Timer "event" without Dialog?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guest's Avatar
    Guest replied
    Lance hits the nail on the head again.
    Just integer divide 9,220,000,000,000,000,000 by Freq.
    That should give you the number of seconds before rollover.
    Code:
    DECLARE FUNCTION QueryPerformanceFrequency LIB "KERNEL32.DLL" ALIAS "QueryPerformanceFrequency" (lpFrequency AS QUAD) AS LONG
    FUNCTION PBMAIN
      LOCAL result AS QUAD, freq AS QUAD
      QueryPerformanceFrequency Freq
      result = 9220000000000000000&& \ freq
      ' seconds \ minutes \ hours \ days \ years
      MSGBOX STR$(result \ 60 \ 60 \ 24 \ 365)
    END FUNCTION
    My P3-500 was about 81676 years.


    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    It is processor dependent. It is also documented in WIN32.HLP... bring up "QueryPerformanceCounter" and click OVERVIEW, then scroll about 3 pages in.

    Basically, you can calculate the period yourself, using "QueryPerformanceFrequency". A LARGE_INTEGER (as WIN32.HLP specifies is equivalent to a QUAD in PowerBASIC.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Colin Schmidt
    replied
    Hello,

    The PerformanceTimer is a nice tool, my AMD 350 is accurate to over 1 billion parts of a second...

    But, if it is counting that fast, how long until it rolls over? The Win32API help file didn't say anything about roll over.

    So I was wondering, if you don't mind, could you share your experience using it?

    Thanks,
    Colin Schmidt

    ------------------
    Colin Schmidt & James Duffy, Praxis Enterprises, Canada

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Here's a sample of using the performance counters.
    Code:
    DECLARE FUNCTION QueryPerformanceCounter LIB "KERNEL32.DLL" ALIAS "QueryPerformanceCounter" (lpPerformanceCount AS QUAD) AS LONG
    DECLARE FUNCTION QueryPerformanceFrequency LIB "KERNEL32.DLL" ALIAS "QueryPerformanceFrequency" (lpFrequency AS QUAD) AS LONG
    FUNCTION PBMAIN
      DIM freq AS QUAD, a AS QUAD, b AS QUAD,overhead AS QUAD, i AS LONG, results AS EXT
      queryperformancefrequency freq
      queryperformancecounter a
      queryperformancecounter b
      overhead = b-a
      queryperformancecounter a
      MSGBOX "close me"
      queryperformancecounter b
      results = ((b - a)-overhead) / freq
      MSGBOX FORMAT$(results,"##0.0000") & " seconds."
    END FUNCTION

    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    As long as we're creating a list...

    1) The CoFileTimeNow API can be used to obtain a QUAD integer with the same properties that Lance described in (3) above, without creating a file. "File time" in this case refers to a data format, not an association with an actual file. The nice thing about a FileTime is that it never rolls over. (At least not for 30,000 years, or something like that, so it would be a Y32K problem.)

    2) Or...
    Code:
        MSGBOX "Click OK and start your stopwatch..."
        SHELL (whatever)
        MSGBOX "Stop the stopwatch NOW!"




    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Lance Edmonds
    replied
    Other options, probably too wild, but just to demonstrate that there are quite a few alternative methods once we use a bit of lateral thinking:

    1. GetTickCOunt() has a resolution in milliseconds and only wraps at 49.7 days. Save the count before the SHELL, and subtrack it after - exactly the same technique as Eric's TIMER suggestion above.

    2. If you are using NT, then you can query "System Up Time" in the HKEY_PERFORMANCE_DATA section of the registry.

    3. Create a "log" file before and after the SHELL, and re-engineer the values stored in the FILETIME structure (which stores the time/date as a "64-bit value representing the number of 100-nanosecond intervals since January 1, 1601"

    4. Use the GetSystemTime() API before and after, etc.




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Eric Pearson
    replied
    Won't the good ol' TIMER function do what you want?

    Code:
    DIM dpStart AS LOCAL DOUBLE
    dpStart = TIMER
    SHELL (whatever)
    dpElapsed = TIMER-dpStart
    It gets a little more complex if the shell operation could "cross midnight" (start before and end after 23:59:59) but you get the idea...

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Timer "event" without Dialog?

    Timer "event" without Dialog?

    Is it possible to time the execution of a PBDLL program without creating or showing a dialog? I want to time the response of a synchronous SHELL but not show any dialog.

    TIA.
Working...
X