Switch CPU profile start/stop markers to monotonic time.
authoralph@chromium.org <alph@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Sat, 19 Apr 2014 14:33:18 +0000 (14:33 +0000)
committeralph@chromium.org <alph@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Sat, 19 Apr 2014 14:33:18 +0000 (14:33 +0000)
LOG=N
BUG=363976
R=bmeurer@chromium.org, yurys@chromium.org

Review URL: https://codereview.chromium.org/243033002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20866 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

include/v8-profiler.h
src/api.cc
src/profile-generator.cc
src/profile-generator.h

index f5b760a..026715f 100644 (file)
@@ -118,14 +118,15 @@ class V8_EXPORT CpuProfile {
   const CpuProfileNode* GetSample(int index) const;
 
   /**
-    * Returns time when the profile recording started (in microseconds
-    * since the Epoch).
+    * Returns time when the profile recording was started (in microseconds)
+    * since some unspecified starting point.
     */
   int64_t GetStartTime() const;
 
   /**
-    * Returns time when the profile recording was stopped (in microseconds
-    * since the Epoch).
+    * Returns time when the profile recording was stopped (in microseconds)
+    * since some unspecified starting point. The point is however equal to the
+    * starting point used by GetStartTime.
     */
   int64_t GetEndTime() const;
 
index 3550bb0..1530ff0 100644 (file)
@@ -7084,13 +7084,13 @@ const CpuProfileNode* CpuProfile::GetSample(int index) const {
 
 int64_t CpuProfile::GetStartTime() const {
   const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
-  return (profile->start_time() - i::Time::UnixEpoch()).InMicroseconds();
+  return (profile->start_time() - i::TimeTicks()).InMicroseconds();
 }
 
 
 int64_t CpuProfile::GetEndTime() const {
   const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
-  return (profile->end_time() - i::Time::UnixEpoch()).InMicroseconds();
+  return (profile->end_time() - i::TimeTicks()).InMicroseconds();
 }
 
 
index 6bd446e..ae37648 100644 (file)
@@ -355,8 +355,7 @@ void ProfileTree::TraverseDepthFirst(Callback* callback) {
 CpuProfile::CpuProfile(const char* title, bool record_samples)
     : title_(title),
       record_samples_(record_samples),
-      start_time_(Time::NowFromSystemTime()) {
-  timer_.Start();
+      start_time_(TimeTicks::HighResolutionNow()) {
 }
 
 
@@ -367,7 +366,7 @@ void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
 
 
 void CpuProfile::CalculateTotalTicksAndSamplingRate() {
-  end_time_ = start_time_ + timer_.Elapsed();
+  end_time_ = TimeTicks::HighResolutionNow();
 }
 
 
index 81980bf..1f23ee2 100644 (file)
@@ -208,8 +208,8 @@ class CpuProfile {
   int samples_count() const { return samples_.length(); }
   ProfileNode* sample(int index) const { return samples_.at(index); }
 
-  Time start_time() const { return start_time_; }
-  Time end_time() const { return end_time_; }
+  TimeTicks start_time() const { return start_time_; }
+  TimeTicks end_time() const { return end_time_; }
 
   void UpdateTicksScale();
 
@@ -218,9 +218,8 @@ class CpuProfile {
  private:
   const char* title_;
   bool record_samples_;
-  Time start_time_;
-  Time end_time_;
-  ElapsedTimer timer_;
+  TimeTicks start_time_;
+  TimeTicks end_time_;
   List<ProfileNode*> samples_;
   ProfileTree top_down_;