forked from wangsibovictor/fora
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmylib.cpp
More file actions
executable file
·51 lines (40 loc) · 841 Bytes
/
mylib.cpp
File metadata and controls
executable file
·51 lines (40 loc) · 841 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
41
42
43
44
45
46
47
48
49
#include "mylib.h"
template<class T>
string toStr(T t) {
stringstream ss;
ss << t;
return ss.str();
}
string __n_variable(string t, int n) {
t = t + ',';
int i = 0;
if (n) for (; i < SIZE(t) && n; i++) if (t[i] == ',') n--;
n = i;
for (; t[i] != ','; i++);
t = t.substr((unsigned long) n, (unsigned long) (i - n));
trim(t);
if (t[0] == '"') return "";
return t + "=";
}
int Counter::cnt[1000] = {0};
vector<double> Timer::timeUsed;
vector<string> Timer::timeUsedDesc;
#ifndef WIN32
#ifdef __CYGWIN__
//CYGWIN
uint64 rdtsc() {
uint64 t0;
asm volatile("rdtsc" : "=A"(t0));
return t0;
}
#else
//LINUX
uint64 rdtsc(void)
{
unsigned a, d;
//asm("cpuid");
asm volatile("rdtsc" : "=a" (a), "=d" (d));
return (((uint64)a) | (((uint64)d) << 32));
}
#endif
#endif