@@ -44,14 +44,7 @@ namespace plugin {
4444 agentCoreFunctions api;
4545 uint32 provid = 0 ;
4646 bool timingOK;
47-
48- #ifdef _WINDOWS
49- LARGE_INTEGER gcSteadyStart, gcSteadyEnd;
50- #elif defined(_LINUX) || defined(_AIX)
51- struct timespec gcSteadyStart, gcSteadyEnd;
52- #elif defined(__MACH__) || defined(__APPLE__) || defined(_ZOS)
53- struct timeval gcSteadyStart, gcSteadyEnd;
54- #endif
47+ uint64_t gcSteadyStart, gcSteadyEnd;
5548}
5649
5750using namespace v8 ;
@@ -62,18 +55,18 @@ static char* NewCString(const std::string& s) {
6255 return result;
6356}
6457
58+ static bool GetSteadyTime (uint64_t * now) {
59+ *now = uv_hrtime ();
60+ return true ;
61+ }
62+ static uint64_t CalculateDuration (uint64_t start, uint64_t finish) {
63+ return (finish - start) / 1000000 ;
64+ }
65+
6566/*
6667 * OSX
6768 */
6869#if defined(__MACH__) || defined(__APPLE__) || defined(_ZOS)
69- static bool GetSteadyTime (struct timeval * tv) {
70- // int rc = clock_gettime(CLOCK_MONOTONIC, tv);
71- int rc = gettimeofday (tv, 0 );
72- return rc == 0 ;
73- }
74- static uint64 CalculateDuration (struct timeval start, struct timeval finish) {
75- return static_cast <uint64>((finish.tv_sec - start.tv_sec ) * 1000 + (finish.tv_usec - start.tv_usec ) / 1000 );
76- }
7770static unsigned long long GetRealTime () {
7871 struct timeval tv;
7972 gettimeofday (&tv, NULL );
@@ -86,13 +79,6 @@ static unsigned long long GetRealTime() {
8679 * Linux
8780 */
8881#if defined(_LINUX) || defined(_AIX)
89- static bool GetSteadyTime (struct timespec * tv) {
90- int rc = clock_gettime (CLOCK_MONOTONIC, tv);
91- return rc == 0 ;
92- }
93- static uint64 CalculateDuration (struct timespec start, struct timespec finish) {
94- return static_cast <uint64>((finish.tv_sec - start.tv_sec ) * 1000 + (finish.tv_nsec - start.tv_nsec ) / 1000000 );
95- }
9682static unsigned long long GetRealTime () {
9783 struct timeval tv;
9884 gettimeofday (&tv, NULL );
@@ -105,26 +91,6 @@ static unsigned long long GetRealTime() {
10591 * Windows
10692 */
10793#ifdef _WINDOWS
108- static LARGE_INTEGER freq;
109- static bool freqInitialized = FALSE ;
110- static bool GetSteadyTime (LARGE_INTEGER* pcount) {
111- if (!freqInitialized) {
112- if (QueryPerformanceFrequency (&freq) == 0 ) {
113- return FALSE ;
114- }
115- freqInitialized = TRUE ;
116- }
117- BOOL rc = QueryPerformanceCounter (pcount);
118- return rc != 0 ;
119- }
120- static uint64 CalculateDuration (LARGE_INTEGER start, LARGE_INTEGER finish) {
121- if (!freqInitialized) return 0L ;
122- LARGE_INTEGER elapsedMilliseconds;
123- elapsedMilliseconds.QuadPart = finish.QuadPart - start.QuadPart ;
124- elapsedMilliseconds.QuadPart *= 1000 ;
125- elapsedMilliseconds.QuadPart /= freq.QuadPart ;
126- return static_cast <uint64>(elapsedMilliseconds.QuadPart );
127- }
12894static unsigned long long GetRealTime () {
12995 SYSTEMTIME st;
13096 GetSystemTime (&st);
0 commit comments