From: Martin Mares Date: Thu, 3 Jul 2003 09:19:10 +0000 (+0000) Subject: Added time measurement library. X-Git-Tag: python-dummy-working~471 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=89703ec0e01ee6d0fac908db85a8e939ae9b2e83;p=moe.git Added time measurement library. --- diff --git a/misc/timelib.h b/misc/timelib.h new file mode 100644 index 0000000..ab37ec5 --- /dev/null +++ b/misc/timelib.h @@ -0,0 +1,5 @@ +#include + +static inline int cpspc_time(void) { + return clock() * 1000 / CLOCKS_PER_SEC; +} diff --git a/misc/timelib.pas b/misc/timelib.pas new file mode 100644 index 0000000..3e1dfcf --- /dev/null +++ b/misc/timelib.pas @@ -0,0 +1,8 @@ +unit timelib; +interface +function cpspc_time:longint;cdecl;external; +{$L timepas.o} +{$LinkLib c} +implementation +begin +end. diff --git a/misc/timepas.c b/misc/timepas.c new file mode 100644 index 0000000..000d22e --- /dev/null +++ b/misc/timepas.c @@ -0,0 +1,6 @@ +#include + +int cpspc_time(void) +{ + return clock() * 1000 / CLOCKS_PER_SEC; +} diff --git a/misc/timetest.c b/misc/timetest.c new file mode 100644 index 0000000..36a0009 --- /dev/null +++ b/misc/timetest.c @@ -0,0 +1,9 @@ +#include +#include "timelib.h" + +int main(void) +{ + int i; + for (i = 0; i <100000000; i++); + printf("%d\n", cpspc_time()); +} diff --git a/misc/timetest.pas b/misc/timetest.pas new file mode 100644 index 0000000..0d996e5 --- /dev/null +++ b/misc/timetest.pas @@ -0,0 +1,6 @@ +uses timelib; +var i:longint; +begin +for i:=1 to 100000000 do i := i; +writeln(cpspc_time); +end.