-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimestamp.cpp
More file actions
46 lines (42 loc) · 1.14 KB
/
Copy pathtimestamp.cpp
File metadata and controls
46 lines (42 loc) · 1.14 KB
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
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define vvpii vector<vpii>
typedef long long ll;
typedef long double ld;
using namespace std;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> void setmax(T& a, T b) { a = max(a, b); };
template<typename T> void setmin(T& a, T b) { a = min(a, b); };
template<typename T> bool in(T lo, T v, T hi) { return lo <= v && v <= hi; };
// useful for profiling algorithms
// (or sections of algorithms)
struct timestamp {
string algo;
ld A, B;
timestamp(string _algo) {
algo = _algo;
A = B = clock();
}
void print() {
ld B_ = clock();
ld section = (B_ - B) / CLOCKS_PER_SEC;
ld cumulative = (B_ - A) / CLOCKS_PER_SEC;
cout << algo << " profile(seconds): section: " << section << " cumulative: " << cumulative << endl << flush;
B = B_;
}
};
int main() {
timestamp t("algo");
int x = 0;
for (int i = 0; i < 1010101; i++) x+=i;
cout << x << endl;
t.print();
}