-
Notifications
You must be signed in to change notification settings - Fork 3
/
app1.C
54 lines (42 loc) · 1006 Bytes
/
app1.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
int64_t numIterations = 0;
int Calc1 (const int num)
{
static int result = 0;
//for (int i = 0; i < num; i++)
for (int i = 0; i < 1000; i++)
{
result += (i*i);
numIterations++;
}
return result;
}
int main (int argc, char* argv[])
{
//const int startValue = atoi(argv[1]);
//int value = int(char(argv[0][0]));
int value = 10;
int64_t maxIterations = int64_t(100) * 1000 * 1000;
if (argc > 1)
{
maxIterations = int64_t( atoi(argv[1]) ) * 1000 * 1000;
}
printf("started with value %d, for %lld iterations\n", value, maxIterations);
while (1)
{
value = Calc1(value);
if ( /*value > 100 * 1000 * 1000 ||*/ value <= 0)
{
value = 10;
}
//usleep(10000);
if (maxIterations > 0 && numIterations > maxIterations)
{
break;
}
}
return value;
}