1 #include <cstdlib>
2 #include <cstdio>
3 
4 using namespace std;
5 
6 double _ntl_GetTime();
7 
8 /* Assuming the processor speed is at most 200GHz, and that
9  * the clock resolution is at least 1 millisecond, the following
10  * code should correctly determine if the GetTime function
11  * is working properly, and should not run for more than
12  * a few seconds on a machine with a speed of at least 100MHz.
13  */
14 
15 #define LOOP_COUNT (400)
16 
main(int argc,char ** argv)17 int main(int argc, char **argv)
18 {
19    long a, x, n, m;
20    long i, j, k;
21    double t0, t1;
22 
23    fprintf(stderr, "running");
24 
25    x = atol(argv[1]); /* = 1 */
26 
27    n = atol(argv[2]); /* = 1048576 = 2^20 */
28 
29    m = atol(argv[3]); /* = 1048575 = 2^20 - 1 */
30 
31    k = -1;
32    t0 = _ntl_GetTime();
33 
34    a = 1;
35 
36    for (i = 1; i <= LOOP_COUNT; i++) {
37       for (j = 0; j < n; j++)
38          a = (a + x) & m;
39 
40       if (a == 17) return -2; /* keeps the compiler honest! */
41 
42       t1 = _ntl_GetTime();
43       if (t1 > t0) { fprintf(stderr, "\n"); return 0; }
44 
45       if ((i % 10) == 0) {
46          fprintf(stderr, ".");
47       }
48    }
49 
50    fprintf(stderr, "\n");
51    return -1;
52 }
53