Commit a554ea37 authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Commit Bot

Reland "[EventTiming] Round instead of ceil the |duration|"

This is a reland of 9ac1e68e

Original change's description:
> [EventTiming] Round instead of ceil the |duration|
> 
> The purpose of this change is to expose entries whose |duration| is >=
> 100ms.
> 
> Bug: 823744
> Change-Id: Ibb089009ba287769b1365a938cc7564278a86c35
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1594818
> Reviewed-by: Timothy Dresser <tdresser@chromium.org>
> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#656797}

Bug: 823744
Change-Id: Ia7ceffaf7dc84951b74fff507b024a3f895039db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1596849Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656927}
parent 393f84b6
......@@ -365,7 +365,7 @@ void WindowPerformance::ReportEventTimings(WebWidgetClient::SwapResult result,
DOMHighResTimeStamp end_time = MonotonicTimeToDOMHighResTimeStamp(timestamp);
for (const auto& entry : event_timings_) {
int duration_in_ms = std::ceil((end_time - entry->startTime()) / 8) * 8;
int duration_in_ms = std::round((end_time - entry->startTime()) / 8) * 8;
entry->SetDuration(duration_in_ms);
if (!first_input_timing_) {
if (entry->name() == "pointerdown") {
......
......@@ -252,6 +252,28 @@ TEST_F(WindowPerformanceTest, EventTimingBeforeOnLoad) {
performance_->clearEventTimings();
}
TEST_F(WindowPerformanceTest, Expose100MsEvents) {
ScopedEventTimingForTest event_timing(true);
TimeTicks start_time = GetTimeOrigin() + TimeDelta::FromSeconds(1);
TimeTicks processing_start = start_time + TimeDelta::FromMilliseconds(10);
TimeTicks processing_end = processing_start + TimeDelta::FromMilliseconds(10);
performance_->RegisterEventTiming("mousedown", start_time, processing_start,
processing_end, false);
TimeTicks start_time2 = start_time + TimeDelta::FromMicroseconds(200);
performance_->RegisterEventTiming("click", start_time2, processing_start,
processing_end, false);
// The swap time is 100.1 ms after |start_time| but only 99.9 ms after
// |start_time2|.
TimeTicks swap_time = start_time + TimeDelta::FromMicroseconds(100100);
SimulateSwapPromise(swap_time);
// Only the longer event should have been reported.
EXPECT_EQ(1u, performance_->getEntriesByType("event").size());
EXPECT_EQ(1u, performance_->getEntriesByName("mousedown", "event").size());
EXPECT_EQ(0u, performance_->getEntriesByName("click", "event").size());
}
TEST_F(WindowPerformanceTest, EventTimingDuration) {
ScopedEventTimingForTest event_timing(true);
......@@ -270,7 +292,7 @@ TEST_F(WindowPerformanceTest, EventTimingDuration) {
performance_->RegisterEventTiming("click", start_time, processing_start,
processing_end, true);
TimeTicks long_swap_time =
GetTimeOrigin() + TimeDelta::FromMilliseconds(1100);
GetTimeOrigin() + TimeDelta::FromMilliseconds(2000);
SimulateSwapPromise(long_swap_time);
EXPECT_EQ(1u, performance_->getEntriesByName("click", "event").size());
......
......@@ -23,7 +23,7 @@
const entry = performance.getEntriesByType('firstInput')[0];
assert_equals(entry.name, 'mousedown');
assert_equals(entry.entryType, 'firstInput');
assert_greater_than(entry.duration, 50,
assert_greater_than_equal(entry.duration, 104,
"The first input was a long one.");
t.done();
}
......
......@@ -35,7 +35,9 @@ function verifyClickEvent(entry, is_first=false) {
"The entry's processingStart should be greater than startTime.");
assert_greater_than_equal(entry.processingEnd, entry.processingStart,
"The entry's processingEnd must be at least as large as processingStart.");
assert_greater_than_equal(entry.duration, entry.processingEnd - entry.startTime,
// |duration| is a number rounded to the nearest 8 ms, so add 4 to get a lower bound
// on the actual duration.
assert_greater_than_equal(entry.duration + 4, entry.processingEnd - entry.startTime,
"The entry's duration must be at least as large as processingEnd - startTime.");
if (is_first) {
let firstInputs = performance.getEntriesByType('firstInput');
......
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