]> mj.ucw.cz Git - moe.git/commitdiff
Added time measurement library.
authorMartin Mares <mj@ucw.cz>
Thu, 3 Jul 2003 09:19:10 +0000 (09:19 +0000)
committerMartin Mares <mj@ucw.cz>
Thu, 3 Jul 2003 09:19:10 +0000 (09:19 +0000)
misc/timelib.h [new file with mode: 0644]
misc/timelib.pas [new file with mode: 0644]
misc/timepas.c [new file with mode: 0644]
misc/timetest.c [new file with mode: 0644]
misc/timetest.pas [new file with mode: 0644]

diff --git a/misc/timelib.h b/misc/timelib.h
new file mode 100644 (file)
index 0000000..ab37ec5
--- /dev/null
@@ -0,0 +1,5 @@
+#include <time.h>
+
+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 (file)
index 0000000..3e1dfcf
--- /dev/null
@@ -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 (file)
index 0000000..000d22e
--- /dev/null
@@ -0,0 +1,6 @@
+#include <time.h>
+
+int cpspc_time(void)
+{
+  return clock() * 1000 / CLOCKS_PER_SEC;
+}
diff --git a/misc/timetest.c b/misc/timetest.c
new file mode 100644 (file)
index 0000000..36a0009
--- /dev/null
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#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 (file)
index 0000000..0d996e5
--- /dev/null
@@ -0,0 +1,6 @@
+uses timelib;
+var i:longint;
+begin
+for i:=1 to 100000000 do i := i;
+writeln(cpspc_time);
+end.