Commit e1d853c7 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

Move timestamp calculation out of the loop

Move timestamp calculation out of the loop by checking for empty
list first, then calculating the timestamp and changing the
loop to a do-while loop.

Change-Id: I4a07abe7b749c85854e75ffdf1d993b602344aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2323371Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Rob Buis <rbuis@igalia.com>
Cr-Commit-Position: refs/heads/master@{#792456}
parent 5408ddfc
...@@ -382,8 +382,11 @@ void WindowPerformance::ReportEventTimings(uint64_t frame_index, ...@@ -382,8 +382,11 @@ void WindowPerformance::ReportEventTimings(uint64_t frame_index,
--pending_swap_promise_count_; --pending_swap_promise_count_;
// |event_timings_| and |event_frames_| should always have the same size. // |event_timings_| and |event_frames_| should always have the same size.
DCHECK(event_timings_.size() == event_frames_.size()); DCHECK(event_timings_.size() == event_frames_.size());
if (event_timings_.IsEmpty())
return;
bool event_timing_enabled = bool event_timing_enabled =
RuntimeEnabledFeatures::EventTimingEnabled(GetExecutionContext()); RuntimeEnabledFeatures::EventTimingEnabled(GetExecutionContext());
DOMHighResTimeStamp end_time = MonotonicTimeToDOMHighResTimeStamp(timestamp);
while (!event_timings_.IsEmpty()) { while (!event_timings_.IsEmpty()) {
PerformanceEventTiming* entry = event_timings_.front(); PerformanceEventTiming* entry = event_timings_.front();
uint64_t entry_frame_index = event_frames_.front(); uint64_t entry_frame_index = event_frames_.front();
...@@ -395,8 +398,6 @@ void WindowPerformance::ReportEventTimings(uint64_t frame_index, ...@@ -395,8 +398,6 @@ void WindowPerformance::ReportEventTimings(uint64_t frame_index,
event_timings_.pop_front(); event_timings_.pop_front();
event_frames_.pop_front(); event_frames_.pop_front();
DOMHighResTimeStamp end_time =
MonotonicTimeToDOMHighResTimeStamp(timestamp);
int duration_in_ms = std::round((end_time - entry->startTime()) / 8) * 8; int duration_in_ms = std::round((end_time - entry->startTime()) / 8) * 8;
entry->SetDuration(duration_in_ms); entry->SetDuration(duration_in_ms);
......
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