Board index » kylix » get time for test...

get time for test...


2004-01-10 11:28:30 AM
kylix0
hi
under windows i use that for obtain time and know how much time a
function... take to run....
uses:
MMSystem
...
...
var
x: double
begin
x :=timeGetTime;
...
end;
how to do that with kylix
thanks
 
 

Re:get time for test...

Try this:
function timeGetTime: Longword;
var
TimeVal: TTimeVal;
begin
gettimeofday(TimeVal, nil);
Result := Longword(1000 * TimeVal.tv_sec + // seconds to milliseconds
TimeVal.tv_usec div 1000); // microseconds to milliseconds
end;
But be aware that Linux systems tend to run for months and not for 47 days
(limitation of timeGetTime)
function timeGetTime64: Int64;
var
TimeVal: TTimeVal;
begin
gettimeofday(TimeVal, nil);
Result := Int64(1000) * TimeVal.tv_sec + // seconds to milliseconds
TimeVal.tv_usec div 1000); // microseconds to milliseconds
end;
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - Kylix 3 patches)
 

Re:get time for test...

Andreas Hausladen wrote:
Quote
Try this:

function timeGetTime: Longword;
var
TimeVal: TTimeVal;
begin
gettimeofday(TimeVal, nil);
Result := Longword(1000 * TimeVal.tv_sec + // seconds to milliseconds
TimeVal.tv_usec div 1000); // microseconds to milliseconds
end;

But be aware that Linux systems tend to run for months and not for 47 days
(limitation of timeGetTime)

function timeGetTime64: Int64;
var
TimeVal: TTimeVal;
begin
gettimeofday(TimeVal, nil);
Result := Int64(1000) * TimeVal.tv_sec + // seconds to milliseconds
TimeVal.tv_usec div 1000); // microseconds to milliseconds
end;


hi
i create a TTimeVal like that:
type
PTimeVal = ^TTimeVal;
{$EXTERNALSYM timeval}
timeval = record
tv_sec: Longint;
tv_usec: Longint;
end;
TTimeVal = timeval;
don't know if it's ok...
that don't work...
gettimeofday don't exist
TTimeVal don't exist
 

{smallsort}

Re:get time for test...

Marc Collin wrote:
Quote
gettimeofday don't exist
TTimeVal don't exist
They are declared in the unit Libc.
--
Regards,
Andreas Hausladen
(www.kylix-patch.de.vu - Kylix 3 patches)