- System time in BB

From: [at]} <Gérard>
Date: Thu, 21 Apr 2005 21:52:13 +0200

----boundary-LibPST-iamunique-871902483_-_-
Content-type: text/plain

Doug,

With this test program, I get a resolution of 3.4 µs on WIN98 600 MHz, and
0.83 µs on XP 1700 MHz:

MODULE UtilTime;

 IMPORT

  StdLog, WinApi;

 VAR

  freq: LONGINT;

 PROCEDURE GetTime* (): REAL;

  VAR

   count: LONGINT;
   ok: INTEGER;

  BEGIN (*GetTime*)
   ok := WinApi.QueryPerformanceCounter(count); ASSERT(ok # 0, 100);
   RETURN count / freq;
  END GetTime;

 PROCEDURE TestTime*;

  CONST

   loops = 10000;

  VAR

   dt, t0, t1: REAL;
   i: INTEGER;

  BEGIN (*TestTime*)
   dt := MAX(REAL);
   t0 := GetTime();
   FOR i := 1 TO loops DO
    t1 := GetTime();
    IF t1 > t0 THEN
     dt := MIN(t1 - t0, dt);
    END;
    t0 := t1;
   END;
   StdLog.String("dt = ");
   StdLog.Real(dt);
   StdLog.Ln;
  END TestTime;

 PROCEDURE Init;

  VAR

   ok: INTEGER;

  BEGIN (*Init*)
   ok := WinApi.QueryPerformanceFrequency(freq); ASSERT(ok # 0, 100);
  END Init;

 BEGIN (*UtilTime*)
  Init;
 END UtilTime.

<Ctrl-Q> UtilTime.TestTime;

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-871902483_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0Ymxccm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o9IEdldFRpbWUoKTtccGFyDQogICBGT1IgaSA6PSAx
IFRPIGxvb3BzIERPXHBhcg0KICAgIHQxIDo9IEdldFRpbWUoKTtccGFyDQogICAgSUYgdDEgPiB0
MCBUSEVOXHBhcg0KICAgICBkdCA6PSBNSU4odDEgLSB0MCwgZHQpO1xwYXINCiAgICBFTkQ7XHBh
cg0KICAgIHQwIDo9IHQxO1xwYXINCiAgIEVORDtccGFyDQogICBTdGRMb2cuU3RyaW5nKCJkdCA9
ICIpO1xwYXINCiAgIFN0ZExvZy5SZWFsKGR0KTtccGFyDQogICBTdGRMb2cuTG47XHBhcg0KICBF
TkQgVGVzdFRpbWU7XHBhcg0KXHBhcg0KIFBST0NFRFVSRSBJbml0O1xwYXINClxwYXINCiAgVkFS
XHBhcg0KXHBhcg0KICAgb2s6IElOVEVHRVI7XHBhcg0KXHBhcg0KICBCRUdJTiAoKkluaXQqKVxw
YXINCiAgIG9rIDo9IFdpbkFwaS5RdWVyeVBlcmZvcm1hbmNlRnJlcXVlbmN5KGZyZXEpOyBBU1NF
UlQob2sgIyAwLCAxMDApO1xwYXINCiAgRU5EIEluaXQ7XHBhcg0KXHBhcg0KIEJFR0lOICgqVXRp
bFRpbWUqKVxwYXINCiAgSW5pdDtccGFyDQogRU5EIFV0aWxUaW1lLlxwYXINClxwYXINCjxDdHJs
LVE+IFV0aWxUaW1lLlRlc3RUaW1lO1xwYXINClxwYXINCi0tLSBCbGFja0JveFxwYXINCi0tLSBz
ZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBibGFja2JveEBvYmVyb24uY2hccGFy
DQpccGFyDQp9


----boundary-LibPST-iamunique-871902483_-_---
Received on Thu Apr 21 2005 - 21:52:13 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:17 UTC