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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 522903002: cc: Be less aggressive about scheduling for scroll handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed scheduler part. Created 6 years, 3 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
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 #include "cc/scheduler/scheduler.h" 4 #include "cc/scheduler/scheduler.h"
5 5
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 } 1039 }
1040 1040
1041 private: 1041 private:
1042 base::TimeDelta draw_duration_; 1042 base::TimeDelta draw_duration_;
1043 base::TimeDelta begin_main_frame_to_commit_duration_; 1043 base::TimeDelta begin_main_frame_to_commit_duration_;
1044 base::TimeDelta commit_to_activate_duration_; 1044 base::TimeDelta commit_to_activate_duration_;
1045 }; 1045 };
1046 1046
1047 void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms, 1047 void MainFrameInHighLatencyMode(int64 begin_main_frame_to_commit_estimate_in_ms,
1048 int64 commit_to_activate_estimate_in_ms, 1048 int64 commit_to_activate_estimate_in_ms,
1049 bool smoothness_takes_priority, 1049 bool impl_latency_takes_priority,
1050 bool should_send_begin_main_frame) { 1050 bool should_send_begin_main_frame) {
1051 // Set up client with specified estimates (draw duration is set to 1). 1051 // Set up client with specified estimates (draw duration is set to 1).
1052 SchedulerClientWithFixedEstimates client( 1052 SchedulerClientWithFixedEstimates client(
1053 base::TimeDelta::FromMilliseconds(1), 1053 base::TimeDelta::FromMilliseconds(1),
1054 base::TimeDelta::FromMilliseconds( 1054 base::TimeDelta::FromMilliseconds(
1055 begin_main_frame_to_commit_estimate_in_ms), 1055 begin_main_frame_to_commit_estimate_in_ms),
1056 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); 1056 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms));
1057 SchedulerSettings default_scheduler_settings; 1057 SchedulerSettings default_scheduler_settings;
1058 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings); 1058 TestScheduler* scheduler = client.CreateScheduler(default_scheduler_settings);
1059 scheduler->SetCanStart(); 1059 scheduler->SetCanStart();
1060 scheduler->SetVisible(true); 1060 scheduler->SetVisible(true);
1061 scheduler->SetCanDraw(true); 1061 scheduler->SetCanDraw(true);
1062 scheduler->SetSmoothnessTakesPriority(smoothness_takes_priority); 1062 scheduler->SetImplLatencyTakesPriority(impl_latency_takes_priority);
1063 InitializeOutputSurfaceAndFirstCommit(scheduler, &client); 1063 InitializeOutputSurfaceAndFirstCommit(scheduler, &client);
1064 1064
1065 // Impl thread hits deadline before commit finishes. 1065 // Impl thread hits deadline before commit finishes.
1066 client.Reset(); 1066 client.Reset();
1067 scheduler->SetNeedsCommit(); 1067 scheduler->SetNeedsCommit();
1068 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1068 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1069 scheduler->BeginFrame(CreateBeginFrameArgsForTesting()); 1069 scheduler->BeginFrame(CreateBeginFrameArgsForTesting());
1070 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode()); 1070 EXPECT_FALSE(scheduler->MainThreadIsInHighLatencyMode());
1071 client.task_runner().RunPendingTasks(); // Run posted deadline. 1071 client.task_runner().RunPendingTasks(); // Run posted deadline.
1072 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode()); 1072 EXPECT_TRUE(scheduler->MainThreadIsInHighLatencyMode());
(...skipping 26 matching lines...) Expand all
1099 // before the deadline (~8ms by default). 1099 // before the deadline (~8ms by default).
1100 MainFrameInHighLatencyMode(10, 1, false, true); 1100 MainFrameInHighLatencyMode(10, 1, false, true);
1101 } 1101 }
1102 1102
1103 TEST(SchedulerTest, NotSkipMainFrameIfHighLatencyAndCanActivateTooLong) { 1103 TEST(SchedulerTest, NotSkipMainFrameIfHighLatencyAndCanActivateTooLong) {
1104 // Set up client so that estimates indicate that the activate cannot finish 1104 // Set up client so that estimates indicate that the activate cannot finish
1105 // before the deadline (~8ms by default). 1105 // before the deadline (~8ms by default).
1106 MainFrameInHighLatencyMode(1, 10, false, true); 1106 MainFrameInHighLatencyMode(1, 10, false, true);
1107 } 1107 }
1108 1108
1109 TEST(SchedulerTest, NotSkipMainFrameInPreferSmoothnessMode) { 1109 TEST(SchedulerTest, NotSkipMainFrameInPreferImplLatencyMode) {
1110 // Set up client so that estimates indicate that we can commit and activate 1110 // Set up client so that estimates indicate that we can commit and activate
1111 // before the deadline (~8ms by default), but also enable smoothness takes 1111 // before the deadline (~8ms by default), but also enable impl latency takes
1112 // priority mode. 1112 // priority mode.
1113 MainFrameInHighLatencyMode(1, 1, true, true); 1113 MainFrameInHighLatencyMode(1, 1, true, true);
1114 } 1114 }
1115 1115
1116 TEST(SchedulerTest, PollForCommitCompletion) { 1116 TEST(SchedulerTest, PollForCommitCompletion) {
1117 // Since we are simulating a long commit, set up a client with draw duration 1117 // Since we are simulating a long commit, set up a client with draw duration
1118 // estimates that prevent skipping main frames to get to low latency mode. 1118 // estimates that prevent skipping main frames to get to low latency mode.
1119 SchedulerClientWithFixedEstimates client( 1119 SchedulerClientWithFixedEstimates client(
1120 base::TimeDelta::FromMilliseconds(1), 1120 base::TimeDelta::FromMilliseconds(1),
1121 base::TimeDelta::FromMilliseconds(32), 1121 base::TimeDelta::FromMilliseconds(32),
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); 1917 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive());
1918 1918
1919 client.Reset(); 1919 client.Reset();
1920 client.task_runner().RunPendingTasks(); // Run posted deadline. 1920 client.task_runner().RunPendingTasks(); // Run posted deadline.
1921 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client); 1921 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client);
1922 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive()); 1922 EXPECT_FALSE(scheduler->IsSyntheticBeginFrameSourceActive());
1923 } 1923 }
1924 1924
1925 } // namespace 1925 } // namespace
1926 } // namespace cc 1926 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine_unittest.cc ('k') | cc/trees/thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698