Revision: 16039
Author:   [email protected]
Date:     Mon Aug  5 00:17:08 2013
Log:      Add start and end profiling time to v8::CpuProfile

I'm going to change CPU profiler API and deprecate GetSelfTime, GetTotalTime and GetTotalSamplesCount on CpuProfileNode as all of those values are derived from self samples count and sampling rate. The sampling rate in turn is calculate based on the profiling duration so having start/end time and total sample count is enough for calculating smpling rate.

BUG=267595
[email protected], [email protected]

Review URL: https://codereview.chromium.org/21918002
http://code.google.com/p/v8/source/detail?r=16039

Modified:
 /branches/bleeding_edge/include/v8-profiler.h
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/profile-generator.h
 /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc

=======================================
--- /branches/bleeding_edge/include/v8-profiler.h       Sat Jul  6 02:12:09 2013
+++ /branches/bleeding_edge/include/v8-profiler.h       Mon Aug  5 00:17:08 2013
@@ -148,6 +148,18 @@
     */
   const CpuProfileNode* GetSample(int index) const;

+  /**
+    * Returns time when the profile recording started (in milliseconds
+    * since the Epoch).
+    */
+  double GetStartTime() const;
+
+  /**
+    * Returns time when the profile recording was stopped (in milliseconds
+    * since the Epoch).
+    */
+  double GetEndTime() const;
+
   /**
    * Deletes the profile and removes it from CpuProfiler's list.
    * All pointers to nodes previously returned become invalid.
=======================================
--- /branches/bleeding_edge/src/api.cc  Fri Aug  2 06:03:06 2013
+++ /branches/bleeding_edge/src/api.cc  Mon Aug  5 00:17:08 2013
@@ -7565,6 +7565,18 @@
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
   return reinterpret_cast<const CpuProfileNode*>(profile->sample(index));
 }
+
+
+double CpuProfile::GetStartTime() const {
+ const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
+  return profile->start_time_ms();
+}
+
+
+double CpuProfile::GetEndTime() const {
+ const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
+  return profile->end_time_ms();
+}


 int CpuProfile::GetSamplesCount() const {
=======================================
--- /branches/bleeding_edge/src/profile-generator.h     Tue Jul 30 00:01:16 2013
+++ /branches/bleeding_edge/src/profile-generator.h     Mon Aug  5 00:17:08 2013
@@ -209,12 +209,15 @@
   void AddPath(const Vector<CodeEntry*>& path);
   void CalculateTotalTicksAndSamplingRate();

-  INLINE(const char* title() const) { return title_; }
-  INLINE(unsigned uid() const) { return uid_; }
-  INLINE(const ProfileTree* top_down() const) { return &top_down_; }
+  const char* title() const { return title_; }
+  unsigned uid() const { return uid_; }
+  const ProfileTree* top_down() const { return &top_down_; }
+
+  int samples_count() const { return samples_.length(); }
+  ProfileNode* sample(int index) const { return samples_.at(index); }

-  INLINE(int samples_count() const) { return samples_.length(); }
- INLINE(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_; }

   void UpdateTicksScale();

=======================================
--- /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Tue Jul 30 00:01:16 2013 +++ /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Mon Aug 5 00:17:08 2013
@@ -408,6 +408,21 @@
   isolate->Dispose();
   CHECK_EQ(NULL, isolate->GetCpuProfiler());
 }
+
+
+TEST(ProfileStartEndTime) {
+  LocalContext env;
+  v8::HandleScope scope(env->GetIsolate());
+  v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
+
+  double time_before_profiling = i::OS::TimeCurrentMillis();
+  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());
+}


 static const v8::CpuProfile* RunProfiler(

--
--
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