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
R=alph@chromium.org, bmeurer@chromium.org
Review URL: https://codereview.chromium.org/
21918002
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16039
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
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.
* Profiles with the same uid but obtained using different
}
+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 {
return reinterpret_cast<const i::CpuProfile*>(this)->samples_count();
}
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_; }
- INLINE(int samples_count() const) { return samples_.length(); }
- INLINE(ProfileNode* sample(int index) const) { return samples_.at(index); }
+ 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_; }
void UpdateTicksScale();
}
+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(
LocalContext& env, v8::Handle<v8::Function> function,
v8::Handle<v8::Value> argv[], int argc,