2008-12-25 11:14 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* include/hbextern.ch
* source/rtl/seconds.c
+ implemented hb_milliseconds(). This function returns time value
from some moment in the past (not midnigth!). It does not start
to cound from zero in midnight, thus, can be safetly used to
measure time intervals.
+ tests/ticktime.c
+ Added nice test for hb_milliseconds().
Results on WinXP:
Ticks per second: 63.595
Min/avg/max interval (ms): 15.000 / 15.724 / 47.000
Loops per tick: 13035.09
Results on openSUSE on VirtualBox on WinXP:
Ticks per second: 384306.138
Min/avg/max interval (ms): 0.001 / 0.003 / 11.112
Loops per tick: 1.04
This commit is contained in:
@@ -8,6 +8,24 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2008-12-25 11:14 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
|
||||
* include/hbextern.ch
|
||||
* source/rtl/seconds.c
|
||||
+ implemented hb_milliseconds(). This function returns time value
|
||||
from some moment in the past (not midnigth!). It does not start
|
||||
to cound from zero in midnight, thus, can be safetly used to
|
||||
measure time intervals.
|
||||
+ tests/ticktime.c
|
||||
+ Added nice test for hb_milliseconds().
|
||||
Results on WinXP:
|
||||
Ticks per second: 63.595
|
||||
Min/avg/max interval (ms): 15.000 / 15.724 / 47.000
|
||||
Loops per tick: 13035.09
|
||||
Results on openSUSE on VirtualBox on WinXP:
|
||||
Ticks per second: 384306.138
|
||||
Min/avg/max interval (ms): 0.001 / 0.003 / 11.112
|
||||
Loops per tick: 1.04
|
||||
|
||||
2008-12-25 08:20 UTC+0200 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
|
||||
* contrib/rddsql/sqlpg/make_b32.bat
|
||||
* contrib/rddsql/sqlpg/make_vc.bat
|
||||
|
||||
@@ -1176,6 +1176,7 @@ EXTERNAL HB_STRSHRINK
|
||||
EXTERNAL HB_MEMOREAD
|
||||
EXTERNAL HB_MEMOWRIT
|
||||
EXTERNAL HB_NTOS
|
||||
EXTERNAL HB_MILLISECONDS
|
||||
|
||||
EXTERNAL HB_HASH
|
||||
EXTERNAL HB_HHASKEY
|
||||
|
||||
@@ -228,11 +228,19 @@ double hb_dateSeconds( void )
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( SECONDS )
|
||||
{
|
||||
hb_retnd( hb_dateSeconds() );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( HB_MILLISECONDS )
|
||||
{
|
||||
hb_retnint( ( HB_LONG ) hb_dateMilliSeconds() );
|
||||
}
|
||||
|
||||
|
||||
HB_FUNC( HB_CLOCKS2SECS )
|
||||
{
|
||||
#ifdef CLOCKS_PER_SEC
|
||||
|
||||
25
harbour/tests/ticktime.prg
Normal file
25
harbour/tests/ticktime.prg
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
PROC main()
|
||||
LOCAL nTime0, nTime, nTimeLast, nMin := 9999, nMax := -9999, nTick := 0, nLoop := 0
|
||||
|
||||
? "Wait for 10 seconds..."
|
||||
nTimeLast := nTime0 := HB_MILLISECONDS()
|
||||
DO WHILE ( nTime := HB_MILLISECONDS() ) - nTime0 < 10000
|
||||
IF nTimeLast != nTime
|
||||
nTick++
|
||||
nMin := MIN(nMin, nTime - nTimeLast)
|
||||
nMax := MAX(nMax, nTime - nTimeLast)
|
||||
nTimeLast := nTime
|
||||
ENDIF
|
||||
nLoop++
|
||||
ENDDO
|
||||
nTime := nTimeLast - nTime0
|
||||
? "Ticks per second:", LTRIM(STR(nTick * 1000/ nTime, 12, 3))
|
||||
? "Min/avg/max interval (ms):", LTRIM(STR(nMin, 9, 3)), "/", ;
|
||||
LTRIM(STR(nTime / nTick, 9, 3)), "/", ;
|
||||
LTRIM(STR(nMax, 9, 3))
|
||||
? "Loops per tick:", nLoop / nTick
|
||||
RETURN
|
||||
Reference in New Issue
Block a user