Skip to content

Commit

Permalink
Switch CPU profile start/stop markers to monotonic time.
Browse files Browse the repository at this point in the history
LOG=N
BUG=363976
R=bmeurer@chromium.org, yurys@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@20866 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information
alph@chromium.org committed Apr 19, 2014
1 parent 8681b78 commit 3f5ec71
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
9 changes: 5 additions & 4 deletions include/v8-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand Down
5 changes: 2 additions & 3 deletions src/profile-generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
}


Expand All @@ -367,7 +366,7 @@ void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {


void CpuProfile::CalculateTotalTicksAndSamplingRate() {
end_time_ = start_time_ + timer_.Elapsed();
end_time_ = TimeTicks::HighResolutionNow();
}


Expand Down
9 changes: 4 additions & 5 deletions src/profile-generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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_;

Expand Down

0 comments on commit 3f5ec71

Please sign in to comment.