Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "platform/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "platform/scheduler/renderer/renderer_scheduler_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/test/histogram_tester.h" | |
| 15 #include "base/test/simple_test_tick_clock.h" | 16 #include "base/test/simple_test_tick_clock.h" |
| 16 #include "cc/output/begin_frame_args.h" | 17 #include "cc/output/begin_frame_args.h" |
| 17 #include "cc/test/ordered_simple_task_runner.h" | 18 #include "cc/test/ordered_simple_task_runner.h" |
| 18 #include "platform/WebTaskRunner.h" | 19 #include "platform/WebTaskRunner.h" |
| 19 #include "platform/scheduler/base/real_time_domain.h" | 20 #include "platform/scheduler/base/real_time_domain.h" |
| 20 #include "platform/scheduler/base/test_time_source.h" | 21 #include "platform/scheduler/base/test_time_source.h" |
| 21 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" | 22 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h" |
| 22 #include "platform/scheduler/child/scheduler_tqm_delegate_impl.h" | 23 #include "platform/scheduler/child/scheduler_tqm_delegate_impl.h" |
| 23 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h" | 24 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h" |
| 24 #include "platform/scheduler/renderer/budget_pool.h" | 25 #include "platform/scheduler/renderer/budget_pool.h" |
| (...skipping 3913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3938 // While the queueing time estimator is locked, we believe the thread to still | 3939 // While the queueing time estimator is locked, we believe the thread to still |
| 3939 // be unresponsive. | 3940 // be unresponsive. |
| 3940 EXPECT_TRUE( | 3941 EXPECT_TRUE( |
| 3941 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold())); | 3942 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold())); |
| 3942 // Once we've dropped the lock, we realize the main thread is responsive. | 3943 // Once we've dropped the lock, we realize the main thread is responsive. |
| 3943 DropQueueingTimeEstimatorLock(); | 3944 DropQueueingTimeEstimatorLock(); |
| 3944 EXPECT_FALSE( | 3945 EXPECT_FALSE( |
| 3945 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold())); | 3946 scheduler_->MainThreadSeemsUnresponsive(responsiveness_threshold())); |
| 3946 } | 3947 } |
| 3947 | 3948 |
| 3949 TEST_F(RendererSchedulerImplTest, MaxQueueingTimeMetric) { | |
| 3950 base::HistogramTester tester; | |
| 3951 // Start with a long task. The long queueing time of the task will be | |
| 3952 // ignored because max queueing time is recorded after navigation start | |
|
tdresser
2017/05/30 13:34:44
is recorded -> is only recorded
Liquan (Max) Gu
2017/05/30 19:57:19
Done.
| |
| 3953 // (OnCommitProvisionalLoad). | |
| 3954 AdvanceTimeWithTask(10); | |
| 3955 // Navigation start | |
| 3956 scheduler_->OnCommitProvisionalLoad(); | |
| 3957 // The max queueing time of the following task will be recorded. | |
| 3958 AdvanceTimeWithTask(1); | |
| 3959 scheduler_->OnCommitProvisionalLoad(); | |
| 3960 // The expected queueing time of 1s task in 1s window is 500ms. | |
| 3961 tester.ExpectUniqueSample("RendererScheduler.MaxQueueingTime", 500, 1); | |
| 3962 } | |
| 3963 | |
| 3964 void SetQueueingTimeInThread(RendererSchedulerImpl* scheduler, | |
| 3965 base::SimpleTestTickClock* clock) { | |
| 3966 // Navigation of a webpage start. | |
| 3967 scheduler->OnCommitProvisionalLoad(); | |
| 3968 // Queueing time is recorded with time advanced. | |
| 3969 clock->Advance(base::TimeDelta::FromSeconds(1)); | |
| 3970 } | |
| 3971 | |
| 3972 TEST_F(RendererSchedulerImplTest, MaxQueueingTimeMetricInTwoThreads) { | |
|
tdresser
2017/05/30 13:34:44
We're only ever going to be adding EQT information
Liquan (Max) Gu
2017/05/30 19:57:19
Talked offline with Tim, as SingleSampleMetric alr
| |
| 3973 base::HistogramTester tester; | |
| 3974 | |
| 3975 default_task_runner_->PostTask( | |
| 3976 FROM_HERE, | |
| 3977 base::Bind(&SetQueueingTimeInThread, scheduler_.get(), clock_.get())); | |
| 3978 RunUntilIdle(); | |
| 3979 // Histogram won't be set until next navigation start. | |
| 3980 tester.ExpectUniqueSample("RendererScheduler.MaxQueueingTime", 500, 0); | |
| 3981 scheduler_->OnCommitProvisionalLoad(); | |
| 3982 // The expected queueing time of 1s task in 1s window is 500ms. | |
| 3983 tester.ExpectUniqueSample("RendererScheduler.MaxQueueingTime", 500, 1); | |
| 3984 } | |
| 3985 | |
| 3948 } // namespace scheduler | 3986 } // namespace scheduler |
| 3949 } // namespace blink | 3987 } // namespace blink |
| OLD | NEW |