Reviewers: alph, Benedikt Meurer, loislo,

Message:
This is a fix for cctest/test-cpu-profiler/ProfileStartEndTime failure on
non-sse builds.

Description:
Return start/end profiling time in microseconds instead of milliseconds

The start and end time are now measured in microseconds and the type is int64_t. This way it seems more natural as we are going to support submilisecond sampling
rate soon. Also it fixes cctest/test-cpu-profiler/ProfileStartEndTime test
failure caused by comparison between long double and double.

TEST=cctest/test-cpu-profiler/ProfileStartEndTime
BUG=v8:2824

Please review this at https://codereview.chromium.org/22172002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M include/v8-profiler.h
  M src/api.cc
  M src/profile-generator.h
  M src/profile-generator.cc
  M test/cctest/test-cpu-profiler.cc


Index: include/v8-profiler.h
diff --git a/include/v8-profiler.h b/include/v8-profiler.h
index 7a71bf10f2abebdd4910fe0bfed60fd7e0357f66..7898fef1967f0c86df5fd6d94fde20d3575eb423 100644
--- a/include/v8-profiler.h
+++ b/include/v8-profiler.h
@@ -149,16 +149,16 @@ class V8EXPORT CpuProfile {
   const CpuProfileNode* GetSample(int index) const;

   /**
-    * Returns time when the profile recording started (in milliseconds
+    * Returns time when the profile recording started (in microseconds
     * since the Epoch).
     */
-  double GetStartTime() const;
+  int64_t GetStartTime() const;

   /**
-    * Returns time when the profile recording was stopped (in milliseconds
+    * Returns time when the profile recording was stopped (in microseconds
     * since the Epoch).
     */
-  double GetEndTime() const;
+  int64_t GetEndTime() const;

   /**
    * Deletes the profile and removes it from CpuProfiler's list.
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 60627a39710443b4aef0b17ab570af6a1cc6c4bd..7b2524cc4d77fddea0752f341042956194eadc04 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -7567,15 +7567,15 @@ const CpuProfileNode* CpuProfile::GetSample(int index) const {
 }


-double CpuProfile::GetStartTime() const {
+int64_t CpuProfile::GetStartTime() const {
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
-  return profile->start_time_ms();
+  return profile->start_time_us();
 }


-double CpuProfile::GetEndTime() const {
+int64_t CpuProfile::GetEndTime() const {
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
-  return profile->end_time_ms();
+  return profile->end_time_us();
 }


Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index 4e2e38988a34a29b7f3331bd18532cf01c9bb131..e772a546471e029665960a62020399d5fe096aad 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -376,8 +376,8 @@ CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples)
     : title_(title),
       uid_(uid),
       record_samples_(record_samples),
-      start_time_ms_(OS::TimeCurrentMillis()),
-      end_time_ms_(0) {
+      start_time_us_(OS::Ticks()),
+      end_time_us_(0) {
 }


@@ -388,13 +388,13 @@ void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {


 void CpuProfile::CalculateTotalTicksAndSamplingRate() {
-  end_time_ms_ = OS::TimeCurrentMillis();
+  end_time_us_ = OS::Ticks();
   top_down_.CalculateTotalTicks();

-  double duration = end_time_ms_ - start_time_ms_;
-  if (duration < 1) duration = 1;
+  double duration_ms = (end_time_us_ - start_time_us_) / 1000.;
+  if (duration_ms < 1) duration_ms = 1;
   unsigned ticks = top_down_.root()->total_ticks();
-  double rate = ticks / duration;
+  double rate = ticks / duration_ms;
   top_down_.SetTickRatePerMs(rate);
 }

Index: src/profile-generator.h
diff --git a/src/profile-generator.h b/src/profile-generator.h
index ce2dd307e3183f9ef55082da14a590429c740586..0cc397ed9bf24583d5d12f69b078157b19176312 100644
--- a/src/profile-generator.h
+++ b/src/profile-generator.h
@@ -216,8 +216,8 @@ class CpuProfile {
   int samples_count() const { return samples_.length(); }
   ProfileNode* sample(int index) const { return samples_.at(index); }

-  double start_time_ms() const { return start_time_ms_; }
-  double end_time_ms() const { return end_time_ms_; }
+  int64_t start_time_us() const { return start_time_us_; }
+  int64_t end_time_us() const { return end_time_us_; }

   void UpdateTicksScale();

@@ -228,8 +228,8 @@ class CpuProfile {
   const char* title_;
   unsigned uid_;
   bool record_samples_;
-  double start_time_ms_;
-  double end_time_ms_;
+  int64_t start_time_us_;
+  int64_t end_time_us_;
   List<ProfileNode*> samples_;
   ProfileTree top_down_;

Index: test/cctest/test-cpu-profiler.cc
diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 3f0fb802b9772c57d4709c096f53e6fdc723e7f6..0dfbb2c44c52337ae2067b648c26986674dddacf 100644
--- a/test/cctest/test-cpu-profiler.cc
+++ b/test/cctest/test-cpu-profiler.cc
@@ -415,13 +415,13 @@ TEST(ProfileStartEndTime) {
   v8::HandleScope scope(env->GetIsolate());
   v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();

-  double time_before_profiling = i::OS::TimeCurrentMillis();
+  double time_before_profiling = i::OS::Ticks();
   v8::Local<v8::String> profile_name = v8::String::New("test");
   cpu_profiler->StartCpuProfiling(profile_name);
const v8::CpuProfile* profile = cpu_profiler->StopCpuProfiling(profile_name);
   CHECK(time_before_profiling <= profile->GetStartTime());
   CHECK(profile->GetStartTime() <= profile->GetEndTime());
-  CHECK(profile->GetEndTime() <= i::OS::TimeCurrentMillis());
+  CHECK(profile->GetEndTime() <= i::OS::Ticks());
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to