-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.cpp
44 lines (35 loc) · 853 Bytes
/
test.cpp
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
#include<iostream>
#include <string>
#include <time.h>
using namespace std;
class Calculations
{
public:
int forEachLoopMaxInteger(long max) {
long sum = 0;
for (long n = max; n > 0; n--) {
double foo = n / 17;
sum = sum + n ;
}
return max;
}
long timediff(clock_t t1, clock_t t2) {
long elapsed;
elapsed = ((double)t2 - t1) / CLOCKS_PER_SEC * 1000;
return elapsed;
}
};
int main()
{
Calculations calculations;
clock_t t1, t2;
int i;
float x = 2.7182;
long elapsed;
t1 = clock();
calculations.forEachLoopMaxInteger(100000000);
t2 = clock();
elapsed = calculations.timediff(t1, t2);
printf("C++: %ldms\n", elapsed);
return 0;
}