summaryrefslogtreecommitdiff
path: root/src/node_perf.h
diff options
context:
space:
mode:
authorTimothy Gu <timothygu99@gmail.com>2018-02-25 14:26:22 -0800
committerJames M Snell <jasnell@gmail.com>2018-03-06 07:50:01 -0800
commit9256dbb6115021fb69d5ccc2af0f7e27b0601007 (patch)
tree9127d1ce78731e3ff76f21517fb5c2b0162b0636 /src/node_perf.h
parentad721429c02a086373d841206927718048d6b521 (diff)
downloadandroid-node-v8-9256dbb6115021fb69d5ccc2af0f7e27b0601007.tar.gz
android-node-v8-9256dbb6115021fb69d5ccc2af0f7e27b0601007.tar.bz2
android-node-v8-9256dbb6115021fb69d5ccc2af0f7e27b0601007.zip
perf_hooks: fix timing
Fixes: https://github.com/nodejs/node/issues/17892 Fixes: https://github.com/nodejs/node/issues/17893 Fixes: https://github.com/nodejs/node/issues/18992 PR-URL: https://github.com/nodejs/node/pull/18993 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'src/node_perf.h')
-rw-r--r--src/node_perf.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/node_perf.h b/src/node_perf.h
index 82e3f46eb8..0db99acd03 100644
--- a/src/node_perf.h
+++ b/src/node_perf.h
@@ -23,6 +23,10 @@ using v8::Local;
using v8::Object;
using v8::Value;
+extern const uint64_t timeOrigin;
+
+double GetCurrentTimeInMicroseconds();
+
static inline PerformanceMilestone ToPerformanceMilestoneEnum(const char* str) {
#define V(name, label) \
if (strcmp(str, label) == 0) return NODE_PERFORMANCE_MILESTONE_##name;
@@ -78,11 +82,11 @@ class PerformanceEntry {
return ToPerformanceEntryTypeEnum(type().c_str());
}
- double startTime() const { return startTime_ / 1e6; }
+ double startTime() const { return startTimeNano() / 1e6; }
double duration() const { return durationNano() / 1e6; }
- uint64_t startTimeNano() const { return startTime_; }
+ uint64_t startTimeNano() const { return startTime_ - timeOrigin; }
uint64_t durationNano() const { return endTime_ - startTime_; }