2011-11-17 09:46 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/contrib/hbwin/hbwapi.h
  * harbour/contrib/hbwin/wapi_winbase.c
  * harbour/contrib/hbwin/hbwin.hbx
    + added to new WIN API wrappers:
         WAPI_QueryPerformanceCounter( @nCounter ) -> <lSuccess>
         WAPI_QueryPerformanceFrequency( @nFrequency ) -> <lSuccess>
      Warning: read in MSDN about above functions and possible
               interactions with multi CPU machines.

  * harbour/contrib/hbwin/win_misc.c
  * harbour/contrib/hbwin/hbwin.hbx
    + added new function which converts QueryPerformance counters
      to seconds:
         WIN_QPCOUNTER2SEC( nCounter ) -> <nSeconds>
      I suggest to use it to convert difference between two calls
      to WAPI_QueryPerformanceCounter(), i.e.:
         WAPI_QueryPerformanceCounter( @nCounterStart )
         [...]
         WAPI_QueryPerformanceCounter( @nCounterEnd )
         ? "total time:", ;
           WIN_QPCOUNTER2SEC( nCounterEnd - nCounterStart ), "sec."
This commit is contained in:
Przemyslaw Czerpak
2011-11-17 08:47:11 +00:00
parent 7132c43df2
commit 4ba52ddb70
5 changed files with 71 additions and 0 deletions

View File

@@ -16,6 +16,29 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-11-17 09:46 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbwin/hbwapi.h
* harbour/contrib/hbwin/wapi_winbase.c
* harbour/contrib/hbwin/hbwin.hbx
+ added to new WIN API wrappers:
WAPI_QueryPerformanceCounter( @nCounter ) -> <lSuccess>
WAPI_QueryPerformanceFrequency( @nFrequency ) -> <lSuccess>
Warning: read in MSDN about above functions and possible
interactions with multi CPU machines.
* harbour/contrib/hbwin/win_misc.c
* harbour/contrib/hbwin/hbwin.hbx
+ added new function which converts QueryPerformance counters
to seconds:
WIN_QPCOUNTER2SEC( nCounter ) -> <nSeconds>
I suggest to use it to convert difference between two calls
to WAPI_QueryPerformanceCounter(), i.e.:
WAPI_QueryPerformanceCounter( @nCounterStart )
[...]
WAPI_QueryPerformanceCounter( @nCounterEnd )
? "total time:", ;
WIN_QPCOUNTER2SEC( nCounterEnd - nCounterStart ), "sec."
2011-11-15 23:28 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/rtl/hbproces.c
* added workaround for missing chroot() in OpenWatcom 1.9 linux libraries

View File

@@ -124,6 +124,14 @@
# endif
#endif
#if defined( __BORLANDC__ )
# define HBWAPI_GET_LARGEUINT( v ) ( ( HB_MAXUINT ) (v).u.LowPart | \
( ( HB_MAXUINT ) (v).u.HighPart << 32 ) )
#else
# define HBWAPI_GET_LARGEUINT( v ) ( ( HB_MAXUINT ) (v).LowPart | \
( ( HB_MAXUINT ) (v).HighPart << 32 ) )
#endif
HB_EXTERN_BEGIN
/* Intentionally not used HB_EXPORT. These are UNICODE setting dependent functions,

View File

@@ -145,6 +145,8 @@ DYNAMIC WAPI_MULDIV
DYNAMIC WAPI_OPENMUTEX
DYNAMIC WAPI_OUTPUTDEBUGSTRING
DYNAMIC WAPI_PLAYSOUND
DYNAMIC WAPI_QUERYPERFORMANCECOUNTER
DYNAMIC WAPI_QUERYPERFORMANCEFREQUENCY
DYNAMIC WAPI_RECTANGLE
DYNAMIC WAPI_RELEASEMUTEX
DYNAMIC WAPI_REMOVEFONTRESOURCE
@@ -372,6 +374,7 @@ DYNAMIC WIN_PRINTERSETDEFAULT
DYNAMIC WIN_PRINTERSTATUS
DYNAMIC WIN_PRINTFILERAW
DYNAMIC WIN_PRN
DYNAMIC WIN_QPCOUNTER2SEC
DYNAMIC WIN_RECTANGLE
DYNAMIC WIN_REGCLOSEKEY
DYNAMIC WIN_REGCREATEKEYEX

View File

@@ -452,3 +452,22 @@ HB_FUNC( WAPI_GETWINDOWSDIRECTORY )
}
#endif
}
HB_FUNC( WAPI_QUERYPERFORMANCECOUNTER )
{
LARGE_INTEGER counter;
BOOL result = QueryPerformanceCounter( &counter );
if( result )
hb_stornint( HBWAPI_GET_LARGEUINT( counter ), 1 );
hb_retl( result != 0 );
}
HB_FUNC( WAPI_QUERYPERFORMANCEFREQUENCY )
{
LARGE_INTEGER frequency;
BOOL result = QueryPerformanceFrequency( &frequency );
if( result )
hb_stornint( HBWAPI_GET_LARGEUINT( frequency ), 1 );
hb_retl( result != 0 );
}

View File

@@ -62,6 +62,7 @@
*/
#include "hbwin.h"
#include "hbwapi.h"
#include "hbapiitm.h"
#ifndef QS_ALLPOSTMESSAGE
@@ -312,3 +313,20 @@ HB_FUNC( WIN_SYSREFRESH )
CloseHandle( hDummyEvent );
hb_retni( 0 );
}
HB_FUNC( WIN_QPCOUNTER2SEC )
{
static HB_MAXDBL s_dFrequence = 0;
if( s_dFrequence == 0 )
{
LARGE_INTEGER frequency;
if( !QueryPerformanceFrequency( &frequency ) )
{
hb_retnd( 0 );
return;
}
s_dFrequence = ( HB_MAXDBL ) HBWAPI_GET_LARGEUINT( frequency );
}
hb_retnd( ( HB_MAXDBL ) hb_parnint( 1 ) / s_dFrequence );
}