Bug 1188616 - CPOW monitoring should use JS_Now instead of PR_IntervalNow. r=jandem

This commit is contained in:
David Rajchenbach-Teller 2015-07-30 14:29:52 +02:00
parent d0a2a9c530
commit 744298baef
2 changed files with 11 additions and 4 deletions

View File

@ -9,6 +9,8 @@
#include "nsContentUtils.h"
#include "CPOWTimer.h"
#include "jsapi.h"
CPOWTimer::CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(nullptr)
, startInterval_(0)
@ -18,7 +20,7 @@ CPOWTimer::CPOWTimer(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
if (!js::GetStopwatchIsMonitoringCPOW(runtime))
return;
cx_ = cx;
startInterval_ = PR_IntervalNow();
startInterval_ = JS_Now();
}
CPOWTimer::~CPOWTimer()
{
@ -33,7 +35,12 @@ CPOWTimer::~CPOWTimer()
return;
}
const int64_t endInterval = JS_Now();
if (endInterval <= startInterval_) {
// Do not assume monotonicity.
return;
}
js::PerformanceData* performance = js::GetPerformanceData(runtime);
uint64_t duration = PR_IntervalToMicroseconds(PR_IntervalNow() - startInterval_);
performance->totalCPOWTime += duration;
performance->totalCPOWTime += endInterval - startInterval_;
}

View File

@ -38,7 +38,7 @@ class MOZ_STACK_CLASS CPOWTimer final {
* The instant at which the stopwatch was started. Undefined
* if CPOW monitoring was off when the timer was created.
*/
PRIntervalTime startInterval_;
int64_t startInterval_;
};
#endif