Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

At 31 AUG 2010 08:35:16PM Stephen Reynolds wrote:

I am trying to loop through some code that has to be timed very precisely. I have tried using the dostime function but it sometimes it gives me negative values, making my calculations inconsistent. I am trying to call a function named QueryPerformanceCounter from Windows Kernal32.dll. I am not able to get this DLL call to work. Any suggestions would be appreciated.

SYSPROCS Record looks like:

BOOL STDCALL QueryPerformanceCounter(LONG);


At 01 SEP 2010 04:29AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

Stephen,

Here's the MS declaration:

BOOL WINAPI QueryPerformanceCounter(
    LARGE_INTEGER *lpPerformanceCount
);

Two problems with your prototype:

1) OI prototyping doesn't understand BOOL - that's just a Windows alias for an integer which OI does understand, so your return type should be an INT instead.

2) The argument passed to the function needs to be a pointer to a LARGE_INTEGER, which is actually a 64-bit integer. The current version of the OI DLL interface code doesn't support 64-bit ints, but MS do specify that you can use a structure instead which has two members - the LowPart (a 32-bit DWORD or Unsigned integer), and a 32-bit integer for the High Part.

So you could try this:

1) Prototype your function as:

   INT STDCALL QueryPerformanceCounter( LPBINARY )

(LPBINARY means pass a pointer to a binary structure)

2) Use the DEFINE_STRUCT window to create a LONG_INTEGER structure with two fields:

   Unsigned Long
   Long

3) In your code do something like:

.bpPre {

 font-family:Consolas,Courier New,Courier,Verdana,Arial;
 font-size:10pt;
 background-color:#FEFEFE;
 color:#000000;
 border:1px solid #7389AE;
 padding:10px 20px;
 margin:0px 10px auto;

}

.bpComment {

 font-style:italic;
 color:#008000;

}

.bpDirective {

 color:#808000;

}

.bpKeyword {

 color:#0000FF;

}

.bpNumber {

 color:#800000;

}

.bpString {

 color:#008080;

}

.bpSymbol {

 color:#800040;

}

.bpSysVar {

 color:#8000FF;

}

.bpDebug {

 font-size:12pt;
 font-weight:bold;
 color:#FF0000;

}

.bpDict {

 color:#FF8000;

}

.bpLabel {

 font-size:11pt;
 font-weight:bold;

}

.bpLineNo {

 font-family:Courier New, Courier, monospace;
 color:#808080;
 background-color:#F5F5F5;

}

   declare function QueryPerformanceCounter, blank_Struct, struct_To_Var
   
   counter = blank_Struct( "LARGE_INTEGER" )
   
   if QueryPerformanceCounter( counter ) then
      
      counter = struct_To_Var( counter, "LARGE_INTEGER" )
      
      lowPart  = counter<1>
      highPart = counter<2>
      
   end

The Sprezzatura Group

The Sprezzatura Blog

World leaders in all things RevSoft


At 01 SEP 2010 07:03AM [url=http://www.sprezzatura.com]The Sprezzatura Group[/url] wrote:

For the purpose of completeness you could also use timeGetTime http://msdn.microsoft.com/en-us/library/dd757629%28VS.85%29.aspx

The Sprezzatura Group

The Sprezzatura Blog

World leaders in all things RevSoft


At 02 SEP 2010 06:21AM Eric wrote:

Getwebtime(void) was available with OI 4.13 which tells you where in Peru your eggs will be ready according to Brazilian time minus two hours.

Hint: There's never a good time for a Brazilian (ouch!)


At 02 SEP 2010 06:27AM Eric wrote:

GetSystemTime() is granulated at 1 ms - 1 January 1601 to AD 30,828

GetSystemTimeAsFileTime() is granulated to the nearest 100 ns

Or you can go by the phases of Jupiter…

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/b3c2984ca04b2af68525779100033a9a.txt
  • Last modified: 2024/01/04 21:00
  • by 127.0.0.1