source: git/ntl/src/TestGetTime.c @ 33a041

spielwiese
Last change on this file since 33a041 was 2cfffe, checked in by Hans Schönemann <hannes@…>, 21 years ago
This commit was generated by cvs2svn to compensate for changes in r6316, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6317 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.2 KB
Line 
1
2
3#include <NTL/config.h>
4
5#include <stdlib.h>
6#include <stdio.h>
7
8#if (defined(__cplusplus) && !defined(NTL_CXX_ONLY))
9extern "C" double _ntl_GetTime();
10#else
11extern double _ntl_GetTime();
12#endif
13
14/* Assuming the processor speed is at most 200GHz, and that
15 * the clock resolution is at least 1 millisecond, the following
16 * code should correctly determine if the GetTime function
17 * is working properly, and should not run for more than
18 * a few seconds on a machine with a speed of at least 100MHz.
19 */
20
21#define LOOP_COUNT (400)
22
23int main(int argc, char **argv)
24{
25   long a, x, n, m;
26   long i, j, k;
27   double t0, t1;
28
29   fprintf(stderr, "running");
30
31   x = atol(argv[1]); /* = 1 */
32
33   n = atol(argv[2]); /* = 1048576 = 2^20 */
34
35   m = atol(argv[3]); /* = 1048575 = 2^20 - 1 */
36
37   k = -1;
38   t0 = _ntl_GetTime();
39
40   a = 1;
41   
42   for (i = 1; i <= LOOP_COUNT; i++) {
43      for (j = 0; j < n; j++) 
44         a = (a + x) & m;
45
46      if (a == 17) return -2; /* keeps the compiler honest! */
47
48      t1 = _ntl_GetTime();
49      if (t1 > t0) { fprintf(stderr, "\n"); return 0; }
50
51      if ((i % 10) == 0) {
52         fprintf(stderr, ".");
53      }
54   }
55
56   fprintf(stderr, "\n");
57   return -1;
58}
Note: See TracBrowser for help on using the repository browser.