equal
deleted
inserted
replaced
47 |
47 |
48 FORCEINLINE void Start() {m_start = QueryTime();} |
48 FORCEINLINE void Start() {m_start = QueryTime();} |
49 FORCEINLINE void Stop() {m_acc += QueryTime() - m_start;} |
49 FORCEINLINE void Stop() {m_acc += QueryTime() - m_start;} |
50 FORCEINLINE int Get(int64 coef) {return (int)(m_acc * coef / QueryFrequency());} |
50 FORCEINLINE int Get(int64 coef) {return (int)(m_acc * coef / QueryFrequency());} |
51 |
51 |
52 #if !defined(UNITTEST) && 1 |
|
53 FORCEINLINE int64 QueryTime() {return _rdtsc();} |
52 FORCEINLINE int64 QueryTime() {return _rdtsc();} |
54 FORCEINLINE int64 QueryFrequency() {return ((int64)2200 * 1000000);} |
53 FORCEINLINE int64 QueryFrequency() {return ((int64)2200 * 1000000);} |
55 #elif defined(_WIN32) || defined(_WIN64) |
|
56 FORCEINLINE int64 QueryTime() {LARGE_INTEGER c; QueryPerformanceCounter(&c); return c.QuadPart;} |
|
57 FORCEINLINE int64 QueryFrequency() {LARGE_INTEGER f; QueryPerformanceFrequency(&f); return f.QuadPart;} |
|
58 #elif defined(CLOCK_THREAD_CPUTIME_ID) |
|
59 FORCEINLINE int64 QueryTime() |
|
60 { |
|
61 timespec ts; |
|
62 int ret = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); |
|
63 if (ret != 0) return 0; |
|
64 return (ts.tv_sec * 1000000000LL) + ts.tv_nsec; |
|
65 } |
|
66 FORCEINLINE int64 QueryFrequency() |
|
67 { |
|
68 return 1000000000; |
|
69 } |
|
70 #else |
|
71 int64 QueryTime() {return 0;} |
|
72 int64 QueryFrequency() {return 1;} |
|
73 #endif |
|
74 }; |
54 }; |
75 |
55 |
76 struct CPerfStartReal |
56 struct CPerfStartReal |
77 { |
57 { |
78 CPerformanceTimer* m_pperf; |
58 CPerformanceTimer* m_pperf; |