Commit 68dae9a9 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Use TimeDelta::operator/() more, third_party/blink/renderer/ edition.

Bug: 1104532
Change-Id: I2665571ddd1129feeb4da8ce6dd39cd42a5427e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354951
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798154}
parent 2955d441
...@@ -300,18 +300,23 @@ void LocalFrameUkmAggregator::RecordEndOfFrameMetrics( ...@@ -300,18 +300,23 @@ void LocalFrameUkmAggregator::RecordEndOfFrameMetrics(
base::TimeTicks start, base::TimeTicks start,
base::TimeTicks end, base::TimeTicks end,
cc::ActiveFrameSequenceTrackers trackers) { cc::ActiveFrameSequenceTrackers trackers) {
// Any of the early out's in LocalFrameView::UpdateLifecyclePhases const base::TimeDelta duration = end - start;
// will mean we are not in a main frame update. Recording is triggered const bool have_valid_metrics =
// higher in the stack, so we cannot know to avoid calling this method. // Any of the early outs in LocalFrameView::UpdateLifecyclePhases() will
if (!in_main_frame_update_) { // mean we are not in a main frame update. Recording is triggered higher
// in the stack, so we cannot know to avoid calling this method.
in_main_frame_update_ &&
// In tests it's possible to reach here with zero duration.
(duration > base::TimeDelta());
in_main_frame_update_ = false;
if (!have_valid_metrics) {
// Reset for the next frame to start the next recording period with // Reset for the next frame to start the next recording period with
// clear counters, even when we did not record anything this frame. // clear counters, even when we did not record anything this frame.
ResetAllMetrics(); ResetAllMetrics();
return; return;
} }
in_main_frame_update_ = false;
base::TimeDelta duration = end - start;
bool report_as_pre_fcp = (fcp_state_ != kHavePassedFCP); bool report_as_pre_fcp = (fcp_state_ != kHavePassedFCP);
bool report_fcp_metrics = (fcp_state_ == kThisFrameReachedFCP); bool report_fcp_metrics = (fcp_state_ == kThisFrameReachedFCP);
...@@ -338,8 +343,7 @@ void LocalFrameUkmAggregator::RecordEndOfFrameMetrics( ...@@ -338,8 +343,7 @@ void LocalFrameUkmAggregator::RecordEndOfFrameMetrics(
for (auto& record : main_frame_percentage_records_) { for (auto& record : main_frame_percentage_records_) {
auto percentage = base::ClampRound<base::HistogramBase::Sample>( auto percentage = base::ClampRound<base::HistogramBase::Sample>(
record.interval_duration.InMicrosecondsF() * 100.0 / 100 * record.interval_duration / duration);
duration.InMicrosecondsF());
record.uma_counters_per_bucket[bucket_index]->Count(percentage); record.uma_counters_per_bucket[bucket_index]->Count(percentage);
} }
...@@ -386,14 +390,12 @@ void LocalFrameUkmAggregator::UpdateEventTimeAndUpdateSampleIfNeeded( ...@@ -386,14 +390,12 @@ void LocalFrameUkmAggregator::UpdateEventTimeAndUpdateSampleIfNeeded(
void LocalFrameUkmAggregator::UpdateSample( void LocalFrameUkmAggregator::UpdateSample(
cc::ActiveFrameSequenceTrackers trackers) { cc::ActiveFrameSequenceTrackers trackers) {
current_sample_.primary_metric_duration = primary_metric_.interval_duration; current_sample_.primary_metric_duration = primary_metric_.interval_duration;
float primary_metric_in_microseconds =
primary_metric_.interval_duration.InMicrosecondsF();
for (unsigned i = 0; i < static_cast<unsigned>(kCount); ++i) { for (unsigned i = 0; i < static_cast<unsigned>(kCount); ++i) {
current_sample_.sub_metrics_durations[i] = current_sample_.sub_metrics_durations[i] =
absolute_metric_records_[i].interval_duration; absolute_metric_records_[i].interval_duration;
current_sample_.sub_metric_percentages[i] = base::ClampRound<unsigned>( current_sample_.sub_metric_percentages[i] = base::ClampRound<unsigned>(
main_frame_percentage_records_[i].interval_duration.InMicrosecondsF() * 100 * main_frame_percentage_records_[i].interval_duration /
100.0 / primary_metric_in_microseconds); primary_metric_.interval_duration);
} }
current_sample_.trackers = trackers; current_sample_.trackers = trackers;
} }
......
...@@ -63,8 +63,7 @@ double LayoutProgress::AnimationProgress() const { ...@@ -63,8 +63,7 @@ double LayoutProgress::AnimationProgress() const {
if (!animating_) if (!animating_)
return 0; return 0;
base::TimeDelta elapsed = base::TimeTicks::Now() - animation_start_time_; base::TimeDelta elapsed = base::TimeTicks::Now() - animation_start_time_;
return (elapsed % animation_duration_).InSecondsF() / return (elapsed % animation_duration_) / animation_duration_;
animation_duration_.InSecondsF();
} }
bool LayoutProgress::IsDeterminate() const { bool LayoutProgress::IsDeterminate() const {
......
...@@ -32,8 +32,7 @@ static bool IsFrameRateRelativelyHigh(base::TimeDelta rendering_interval, ...@@ -32,8 +32,7 @@ static bool IsFrameRateRelativelyHigh(base::TimeDelta rendering_interval,
constexpr double kThreshold = 0.05; constexpr double kThreshold = 0.05;
return kThreshold > return kThreshold >
std::abs(1.0 - (rendering_interval.InMillisecondsF() / std::abs(1.0 - (rendering_interval / average_frame_duration));
average_frame_duration.InMillisecondsF()));
} }
} // namespace } // namespace
......
...@@ -83,9 +83,8 @@ TEST_F(WriteBarrierPerfTest, MemberWritePerformance) { ...@@ -83,9 +83,8 @@ TEST_F(WriteBarrierPerfTest, MemberWritePerformance) {
reporter.AddResult( reporter.AddResult(
kMetricWritesOutsideGcRunsPerS, kMetricWritesOutsideGcRunsPerS,
static_cast<double>(kNumElements) / outside_gc_duration.InSecondsF()); static_cast<double>(kNumElements) / outside_gc_duration.InSecondsF());
reporter.AddResult( reporter.AddResult(kMetricRelativeSpeedDifferenceUnitless,
kMetricRelativeSpeedDifferenceUnitless, during_gc_duration / outside_gc_duration);
during_gc_duration.InSecondsF() / outside_gc_duration.InSecondsF());
} }
} // namespace blink } // namespace blink
...@@ -117,8 +117,7 @@ void ThreadLoadTracker::Advance(base::TimeTicks now, TaskState task_state) { ...@@ -117,8 +117,7 @@ void ThreadLoadTracker::Advance(base::TimeTicks now, TaskState task_state) {
} }
double ThreadLoadTracker::Load() { double ThreadLoadTracker::Load() {
return run_time_inside_window_.InSecondsF() / return run_time_inside_window_ / reporting_interval_;
reporting_interval_.InSecondsF();
} }
} // namespace scheduler } // namespace scheduler
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment