Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: content/browser/renderer_host/input/render_widget_host_latency_tracker_unittest.cc

Issue 2051853002: Measure queueing and blocking time for touchstart/touchend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update histograms.xml, fix microseconds -> ms. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/histogram_tester.h" 5 #include "base/test/histogram_tester.h"
6 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h" 6 #include "content/browser/renderer_host/input/render_widget_host_latency_tracker .h"
7 #include "content/common/input/synthetic_web_input_event_builders.h" 7 #include "content/common/input/synthetic_web_input_event_builders.h"
8 #include "content/public/browser/native_web_keyboard_event.h" 8 #include "content/public/browser/native_web_keyboard_event.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 EXPECT_FALSE(scroll_latency.FindLatency( 373 EXPECT_FALSE(scroll_latency.FindLatency(
374 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT, 374 ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT,
375 tracker()->latency_component_id(), nullptr)); 375 tracker()->latency_component_id(), nullptr));
376 EXPECT_TRUE(scroll_latency.FindLatency( 376 EXPECT_TRUE(scroll_latency.FindLatency(
377 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, 377 ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
378 tracker()->latency_component_id(), nullptr)); 378 tracker()->latency_component_id(), nullptr));
379 EXPECT_EQ(3U, scroll_latency.latency_components().size()); 379 EXPECT_EQ(3U, scroll_latency.latency_components().size());
380 } 380 }
381 381
382 TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) { 382 TEST_F(RenderWidgetHostLatencyTrackerTest, TouchBlockingAndQueueingTime) {
383 // These numbers are sensitive to where the histogram buckets are.
384 int touchstart_timestamps_ms[] = {11, 25, 35};
385 int touchmove_timestamps_ms[] = {1, 5, 12};
386 int touchend_timestamps_ms[] = {3, 8, 12};
387
383 for (InputEventAckState blocking : 388 for (InputEventAckState blocking :
384 {INPUT_EVENT_ACK_STATE_NOT_CONSUMED, INPUT_EVENT_ACK_STATE_CONSUMED}) { 389 {INPUT_EVENT_ACK_STATE_NOT_CONSUMED, INPUT_EVENT_ACK_STATE_CONSUMED}) {
385 SyntheticWebTouchEvent event; 390 SyntheticWebTouchEvent event;
386 event.PressPoint(1, 1); 391 {
392 // Touch start.
393 event.PressPoint(1, 1);
387 394
388 ui::LatencyInfo latency_start; 395 ui::LatencyInfo latency;
389 tracker()->OnInputEvent(event, &latency_start); 396 tracker()->OnInputEvent(event, &latency);
390 tracker()->OnInputEventAck(event, &latency_start,
391 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
392 397
393 ui::LatencyInfo latency_move; 398 ui::LatencyInfo fake_latency;
394 event.MovePoint(0, 20, 20); 399 fake_latency.AddLatencyNumberWithTimestamp(
395 tracker()->OnInputEvent(event, &latency_move); 400 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
401 tracker()->latency_component_id(), 0,
402 base::TimeTicks() +
403 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[0]),
404 1);
396 405
397 EXPECT_TRUE(latency_move.FindLatency( 406 fake_latency.AddLatencyNumberWithTimestamp(
398 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr)); 407 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
399 EXPECT_TRUE( 408 base::TimeTicks() +
400 latency_move.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 409 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[1]),
401 tracker()->latency_component_id(), nullptr)); 410 1);
402 411
403 EXPECT_EQ(2U, latency_move.latency_components().size()); 412 fake_latency.AddLatencyNumberWithTimestamp(
413 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0,
414 base::TimeTicks() +
415 base::TimeDelta::FromMilliseconds(touchstart_timestamps_ms[2]),
416 1);
404 417
405 ui::LatencyInfo fake_latency_move; 418 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
406 fake_latency_move.AddLatencyNumberWithTimestamp( 419 // overwriting components.
407 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, 420 tracker()->ComputeInputLatencyHistograms(
408 tracker()->latency_component_id(), 0, 421 event.type, tracker()->latency_component_id(), fake_latency,
409 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1), 1); 422 blocking);
410 423
411 fake_latency_move.AddLatencyNumberWithTimestamp( 424 tracker()->OnInputEventAck(event, &latency,
412 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0, 425 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
413 base::TimeTicks() + base::TimeDelta::FromMilliseconds(5), 1); 426 }
414 427
415 fake_latency_move.AddLatencyNumberWithTimestamp( 428 {
416 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0, 429 // Touch move.
417 base::TimeTicks() + base::TimeDelta::FromMilliseconds(12), 1); 430 ui::LatencyInfo latency;
431 event.MovePoint(0, 20, 20);
432 tracker()->OnInputEvent(event, &latency);
418 433
419 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck 434 EXPECT_TRUE(latency.FindLatency(
420 // overwriting components. 435 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
421 tracker()->ComputeInputLatencyHistograms(event.type, 436 EXPECT_TRUE(
422 tracker()->latency_component_id(), 437 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
423 fake_latency_move, blocking); 438 tracker()->latency_component_id(), nullptr));
439
440 EXPECT_EQ(2U, latency.latency_components().size());
441
442 ui::LatencyInfo fake_latency;
443 fake_latency.AddLatencyNumberWithTimestamp(
444 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
445 tracker()->latency_component_id(), 0,
446 base::TimeTicks() +
447 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[0]),
448 1);
449
450 fake_latency.AddLatencyNumberWithTimestamp(
451 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
452 base::TimeTicks() +
453 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[1]),
454 1);
455
456 fake_latency.AddLatencyNumberWithTimestamp(
457 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0,
458 base::TimeTicks() +
459 base::TimeDelta::FromMilliseconds(touchmove_timestamps_ms[2]),
460 1);
461
462 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
463 // overwriting components.
464 tracker()->ComputeInputLatencyHistograms(
465 event.type, tracker()->latency_component_id(), fake_latency,
466 blocking);
467 }
468
469 {
470 // Touch end.
471 ui::LatencyInfo latency;
472 event.ReleasePoint(0);
473 tracker()->OnInputEvent(event, &latency);
474
475 EXPECT_TRUE(latency.FindLatency(
476 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0, nullptr));
477 EXPECT_TRUE(
478 latency.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
479 tracker()->latency_component_id(), nullptr));
480
481 EXPECT_EQ(2U, latency.latency_components().size());
482
483 ui::LatencyInfo fake_latency;
484 fake_latency.AddLatencyNumberWithTimestamp(
485 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT,
486 tracker()->latency_component_id(), 0,
487 base::TimeTicks() +
488 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[0]),
489 1);
490
491 fake_latency.AddLatencyNumberWithTimestamp(
492 ui::INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT, 0, 0,
493 base::TimeTicks() +
494 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[1]),
495 1);
496
497 fake_latency.AddLatencyNumberWithTimestamp(
498 ui::INPUT_EVENT_LATENCY_ACK_RWH_COMPONENT, 0, 0,
499 base::TimeTicks() +
500 base::TimeDelta::FromMilliseconds(touchend_timestamps_ms[2]),
501 1);
502
503 // Call ComputeInputLatencyHistograms directly to avoid OnInputEventAck
504 // overwriting components.
505 tracker()->ComputeInputLatencyHistograms(
506 event.type, tracker()->latency_component_id(), fake_latency,
507 blocking);
508 }
424 } 509 }
425 510
511 // Touch start.
512 EXPECT_THAT(
513 histogram_tester().GetAllSamples(
514 "Event.Latency.QueueingTime.TouchStartDefaultPrevented"),
515 ElementsAre(Bucket(
516 touchstart_timestamps_ms[1] - touchstart_timestamps_ms[0], 1)));
517 EXPECT_THAT(
518 histogram_tester().GetAllSamples(
519 "Event.Latency.QueueingTime.TouchStartDefaultAllowed"),
520 ElementsAre(Bucket(
521 touchstart_timestamps_ms[1] - touchstart_timestamps_ms[0], 1)));
522 EXPECT_THAT(
523 histogram_tester().GetAllSamples(
524 "Event.Latency.BlockingTime.TouchStartDefaultPrevented"),
525 ElementsAre(Bucket(
526 touchstart_timestamps_ms[2] - touchstart_timestamps_ms[1], 1)));
527 EXPECT_THAT(
528 histogram_tester().GetAllSamples(
529 "Event.Latency.BlockingTime.TouchStartDefaultAllowed"),
530 ElementsAre(Bucket(
531 touchstart_timestamps_ms[2] - touchstart_timestamps_ms[1], 1)));
532
533 // Touch move.
426 EXPECT_THAT(histogram_tester().GetAllSamples( 534 EXPECT_THAT(histogram_tester().GetAllSamples(
427 "Event.Latency.QueueingTime.TouchMoveDefaultPrevented"), 535 "Event.Latency.QueueingTime.TouchMoveDefaultPrevented"),
428 ElementsAre(Bucket(4, 1))); 536 ElementsAre(Bucket(
537 touchmove_timestamps_ms[1] - touchmove_timestamps_ms[0], 1)));
429 EXPECT_THAT(histogram_tester().GetAllSamples( 538 EXPECT_THAT(histogram_tester().GetAllSamples(
430 "Event.Latency.QueueingTime.TouchMoveDefaultAllowed"), 539 "Event.Latency.QueueingTime.TouchMoveDefaultAllowed"),
431 ElementsAre(Bucket(4, 1))); 540 ElementsAre(Bucket(
541 touchmove_timestamps_ms[1] - touchmove_timestamps_ms[0], 1)));
432 EXPECT_THAT(histogram_tester().GetAllSamples( 542 EXPECT_THAT(histogram_tester().GetAllSamples(
433 "Event.Latency.BlockingTime.TouchMoveDefaultPrevented"), 543 "Event.Latency.BlockingTime.TouchMoveDefaultPrevented"),
434 ElementsAre(Bucket(7, 1))); 544 ElementsAre(Bucket(
545 touchmove_timestamps_ms[2] - touchmove_timestamps_ms[1], 1)));
435 EXPECT_THAT(histogram_tester().GetAllSamples( 546 EXPECT_THAT(histogram_tester().GetAllSamples(
436 "Event.Latency.BlockingTime.TouchMoveDefaultAllowed"), 547 "Event.Latency.BlockingTime.TouchMoveDefaultAllowed"),
437 ElementsAre(Bucket(7, 1))); 548 ElementsAre(Bucket(
549 touchmove_timestamps_ms[2] - touchmove_timestamps_ms[1], 1)));
550
551 // Touch end.
552 EXPECT_THAT(histogram_tester().GetAllSamples(
553 "Event.Latency.QueueingTime.TouchEndDefaultPrevented"),
554 ElementsAre(Bucket(
555 touchend_timestamps_ms[1] - touchend_timestamps_ms[0], 1)));
556 EXPECT_THAT(histogram_tester().GetAllSamples(
557 "Event.Latency.QueueingTime.TouchEndDefaultAllowed"),
558 ElementsAre(Bucket(
559 touchend_timestamps_ms[1] - touchend_timestamps_ms[0], 1)));
560 EXPECT_THAT(histogram_tester().GetAllSamples(
561 "Event.Latency.BlockingTime.TouchEndDefaultPrevented"),
562 ElementsAre(Bucket(
563 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
564 EXPECT_THAT(histogram_tester().GetAllSamples(
565 "Event.Latency.BlockingTime.TouchEndDefaultAllowed"),
566 ElementsAre(Bucket(
567 touchend_timestamps_ms[2] - touchend_timestamps_ms[1], 1)));
438 } 568 }
439 569
440 } // namespace content 570 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698