-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
40 lines (36 loc) · 838 Bytes
/
test.cpp
File metadata and controls
40 lines (36 loc) · 838 Bytes
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
#include <iostream>
#include <chrono>
#include <unordered_map>
#include <vector>
#include <random>
#include <algorithm>
#include <map>
__attribute__((noinline)) void stuff(int x) {
long long curr = 0;
for (int i = 0; i < 1000;i++) {
curr += x;
}
std::cout << curr << "\n";
return;
}
inline __attribute__((always_inline)) void stuff1(int x) {
long long curr = 0;
for (int i = 0; i < 1000;i++) {
curr += x;
}
std::cout << curr << "\n";
return;
}
int main() {
int x = 10000000;
auto start = std::chrono::high_resolution_clock::now();
while (x > 0) {
x--;
if (x == 0) {
stuff(x);
}
}
auto end = std::chrono::high_resolution_clock::now();
double c = std::chrono::duration<double>(end - start).count();
std::cout << c;
}