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 "cc/scheduler/compositor_timing_history.h" | 5 #include "cc/scheduler/compositor_timing_history.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "cc/debug/rendering_stats_instrumentation.h" | 9 #include "cc/debug/rendering_stats_instrumentation.h" |
10 | 10 |
11 namespace cc { | 11 namespace cc { |
12 | 12 |
13 class CompositorTimingHistory::UMAReporter { | 13 class CompositorTimingHistory::UMAReporter { |
14 public: | 14 public: |
15 virtual ~UMAReporter() {} | 15 virtual ~UMAReporter() {} |
16 | 16 |
| 17 // Throughput measurements |
| 18 virtual void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) = 0; |
| 19 virtual void AddBeginMainFrameIntervalNotCritical( |
| 20 base::TimeDelta interval) = 0; |
| 21 virtual void AddCommitInterval(base::TimeDelta interval) = 0; |
| 22 virtual void AddDrawInterval(base::TimeDelta interval) = 0; |
| 23 |
| 24 // Latency measurements |
17 virtual void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 25 virtual void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
18 base::TimeDelta estimate, | 26 base::TimeDelta estimate, |
19 bool affects_estimate) = 0; | 27 bool affects_estimate) = 0; |
20 virtual void AddBeginMainFrameQueueDurationCriticalDuration( | 28 virtual void AddBeginMainFrameQueueDurationCriticalDuration( |
21 base::TimeDelta duration, | 29 base::TimeDelta duration, |
22 bool affects_estimate) = 0; | 30 bool affects_estimate) = 0; |
23 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( | 31 virtual void AddBeginMainFrameQueueDurationNotCriticalDuration( |
24 base::TimeDelta duration, | 32 base::TimeDelta duration, |
25 bool affects_estimate) = 0; | 33 bool affects_estimate) = 0; |
26 virtual void AddBeginMainFrameStartToCommitDuration( | 34 virtual void AddBeginMainFrameStartToCommitDuration( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ | 131 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling." category "." subcategory \ |
124 ".NotUsedForEstimate", \ | 132 ".NotUsedForEstimate", \ |
125 duration); \ | 133 duration); \ |
126 } \ | 134 } \ |
127 } while (false) | 135 } while (false) |
128 | 136 |
129 class RendererUMAReporter : public CompositorTimingHistory::UMAReporter { | 137 class RendererUMAReporter : public CompositorTimingHistory::UMAReporter { |
130 public: | 138 public: |
131 ~RendererUMAReporter() override {} | 139 ~RendererUMAReporter() override {} |
132 | 140 |
| 141 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { |
| 142 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( |
| 143 "Scheduling.Renderer.BeginMainFrameIntervalCritical", interval); |
| 144 } |
| 145 |
| 146 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { |
| 147 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( |
| 148 "Scheduling.Renderer.BeginMainFrameIntervalNotCritical", interval); |
| 149 } |
| 150 |
| 151 void AddCommitInterval(base::TimeDelta interval) override { |
| 152 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.CommitInterval", |
| 153 interval); |
| 154 } |
| 155 |
| 156 void AddDrawInterval(base::TimeDelta interval) override { |
| 157 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.DrawInterval", |
| 158 interval); |
| 159 } |
| 160 |
133 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 161 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
134 base::TimeDelta estimate, | 162 base::TimeDelta estimate, |
135 bool affects_estimate) override { | 163 bool affects_estimate) override { |
136 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "BeginMainFrameToCommit"); | 164 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Renderer", "BeginMainFrameToCommit"); |
137 } | 165 } |
138 | 166 |
139 void AddBeginMainFrameQueueDurationCriticalDuration( | 167 void AddBeginMainFrameQueueDurationCriticalDuration( |
140 base::TimeDelta duration, | 168 base::TimeDelta duration, |
141 bool affects_estimate) override { | 169 bool affects_estimate) override { |
142 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( | 170 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 void AddSwapToAckLatency(base::TimeDelta duration) override { | 212 void AddSwapToAckLatency(base::TimeDelta duration) override { |
185 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.SwapToAckLatency", | 213 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Renderer.SwapToAckLatency", |
186 duration); | 214 duration); |
187 } | 215 } |
188 }; | 216 }; |
189 | 217 |
190 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { | 218 class BrowserUMAReporter : public CompositorTimingHistory::UMAReporter { |
191 public: | 219 public: |
192 ~BrowserUMAReporter() override {} | 220 ~BrowserUMAReporter() override {} |
193 | 221 |
| 222 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override { |
| 223 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( |
| 224 "Scheduling.Browser.BeginMainFrameIntervalCritical", interval); |
| 225 } |
| 226 |
| 227 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { |
| 228 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS( |
| 229 "Scheduling.Browser.BeginMainFrameIntervalNotCritical", interval); |
| 230 } |
| 231 |
| 232 void AddCommitInterval(base::TimeDelta interval) override { |
| 233 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.CommitInterval", |
| 234 interval); |
| 235 } |
| 236 |
| 237 void AddDrawInterval(base::TimeDelta interval) override { |
| 238 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.DrawInterval", |
| 239 interval); |
| 240 } |
| 241 |
194 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 242 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
195 base::TimeDelta estimate, | 243 base::TimeDelta estimate, |
196 bool affects_estimate) override { | 244 bool affects_estimate) override { |
197 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "BeginMainFrameToCommit"); | 245 REPORT_COMPOSITOR_TIMING_HISTORY_UMA("Browser", "BeginMainFrameToCommit"); |
198 } | 246 } |
199 | 247 |
200 void AddBeginMainFrameQueueDurationCriticalDuration( | 248 void AddBeginMainFrameQueueDurationCriticalDuration( |
201 base::TimeDelta duration, | 249 base::TimeDelta duration, |
202 bool affects_estimate) override { | 250 bool affects_estimate) override { |
203 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( | 251 REPORT_COMPOSITOR_TIMING_HISTORY_UMA2( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 292 |
245 void AddSwapToAckLatency(base::TimeDelta duration) override { | 293 void AddSwapToAckLatency(base::TimeDelta duration) override { |
246 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.SwapToAckLatency", | 294 UMA_HISTOGRAM_CUSTOM_TIMES_MICROS("Scheduling.Browser.SwapToAckLatency", |
247 duration); | 295 duration); |
248 } | 296 } |
249 }; | 297 }; |
250 | 298 |
251 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { | 299 class NullUMAReporter : public CompositorTimingHistory::UMAReporter { |
252 public: | 300 public: |
253 ~NullUMAReporter() override {} | 301 ~NullUMAReporter() override {} |
| 302 void AddBeginMainFrameIntervalCritical(base::TimeDelta interval) override {} |
| 303 void AddBeginMainFrameIntervalNotCritical(base::TimeDelta interval) override { |
| 304 } |
| 305 void AddCommitInterval(base::TimeDelta interval) override {} |
| 306 void AddDrawInterval(base::TimeDelta interval) override {} |
254 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, | 307 void AddBeginMainFrameToCommitDuration(base::TimeDelta duration, |
255 base::TimeDelta estimate, | 308 base::TimeDelta estimate, |
256 bool affects_estimate) override {} | 309 bool affects_estimate) override {} |
257 void AddBeginMainFrameQueueDurationCriticalDuration( | 310 void AddBeginMainFrameQueueDurationCriticalDuration( |
258 base::TimeDelta duration, | 311 base::TimeDelta duration, |
259 bool affects_estimate) override {} | 312 bool affects_estimate) override {} |
260 void AddBeginMainFrameQueueDurationNotCriticalDuration( | 313 void AddBeginMainFrameQueueDurationNotCriticalDuration( |
261 base::TimeDelta duration, | 314 base::TimeDelta duration, |
262 bool affects_estimate) override {} | 315 bool affects_estimate) override {} |
263 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, | 316 void AddBeginMainFrameStartToCommitDuration(base::TimeDelta duration, |
(...skipping 12 matching lines...) Expand all Loading... |
276 bool affects_estimate) override {} | 329 bool affects_estimate) override {} |
277 void AddSwapToAckLatency(base::TimeDelta duration) override {} | 330 void AddSwapToAckLatency(base::TimeDelta duration) override {} |
278 }; | 331 }; |
279 | 332 |
280 } // namespace | 333 } // namespace |
281 | 334 |
282 CompositorTimingHistory::CompositorTimingHistory( | 335 CompositorTimingHistory::CompositorTimingHistory( |
283 UMACategory uma_category, | 336 UMACategory uma_category, |
284 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 337 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
285 : enabled_(false), | 338 : enabled_(false), |
| 339 did_send_begin_main_frame_(false), |
| 340 begin_main_frame_needed_continuously_(false), |
| 341 begin_main_frame_committing_continuously_(false), |
| 342 compositor_drawing_continuously_(false), |
286 begin_main_frame_sent_to_commit_duration_history_(kDurationHistorySize), | 343 begin_main_frame_sent_to_commit_duration_history_(kDurationHistorySize), |
287 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), | 344 begin_main_frame_queue_duration_critical_history_(kDurationHistorySize), |
288 begin_main_frame_queue_duration_not_critical_history_( | 345 begin_main_frame_queue_duration_not_critical_history_( |
289 kDurationHistorySize), | 346 kDurationHistorySize), |
290 begin_main_frame_start_to_commit_duration_history_(kDurationHistorySize), | 347 begin_main_frame_start_to_commit_duration_history_(kDurationHistorySize), |
291 commit_to_ready_to_activate_duration_history_(kDurationHistorySize), | 348 commit_to_ready_to_activate_duration_history_(kDurationHistorySize), |
292 prepare_tiles_duration_history_(kDurationHistorySize), | 349 prepare_tiles_duration_history_(kDurationHistorySize), |
293 activate_duration_history_(kDurationHistorySize), | 350 activate_duration_history_(kDurationHistorySize), |
294 draw_duration_history_(kDurationHistorySize), | 351 draw_duration_history_(kDurationHistorySize), |
295 begin_main_frame_on_critical_path_(false), | 352 begin_main_frame_on_critical_path_(false), |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 388 } |
332 | 389 |
333 base::TimeTicks CompositorTimingHistory::Now() const { | 390 base::TimeTicks CompositorTimingHistory::Now() const { |
334 return base::TimeTicks::Now(); | 391 return base::TimeTicks::Now(); |
335 } | 392 } |
336 | 393 |
337 void CompositorTimingHistory::SetRecordingEnabled(bool enabled) { | 394 void CompositorTimingHistory::SetRecordingEnabled(bool enabled) { |
338 enabled_ = enabled; | 395 enabled_ = enabled; |
339 } | 396 } |
340 | 397 |
| 398 void CompositorTimingHistory::SetBeginMainFrameNeededContinuously(bool active) { |
| 399 if (active == begin_main_frame_needed_continuously_) |
| 400 return; |
| 401 begin_main_frame_end_time_prev_ = base::TimeTicks(); |
| 402 begin_main_frame_needed_continuously_ = active; |
| 403 } |
| 404 |
| 405 void CompositorTimingHistory::SetBeginMainFrameCommittingContinuously( |
| 406 bool active) { |
| 407 if (active == begin_main_frame_committing_continuously_) |
| 408 return; |
| 409 new_active_tree_draw_end_time_prev_ = base::TimeTicks(); |
| 410 begin_main_frame_committing_continuously_ = active; |
| 411 } |
| 412 |
| 413 void CompositorTimingHistory::SetCompositorDrawingContinuously(bool active) { |
| 414 if (active == compositor_drawing_continuously_) |
| 415 return; |
| 416 draw_end_time_prev_ = base::TimeTicks(); |
| 417 compositor_drawing_continuously_ = active; |
| 418 } |
| 419 |
341 base::TimeDelta | 420 base::TimeDelta |
342 CompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const { | 421 CompositorTimingHistory::BeginMainFrameToCommitDurationEstimate() const { |
343 return begin_main_frame_sent_to_commit_duration_history_.Percentile( | 422 return begin_main_frame_sent_to_commit_duration_history_.Percentile( |
344 kBeginMainFrameToCommitEstimationPercentile); | 423 kBeginMainFrameToCommitEstimationPercentile); |
345 } | 424 } |
346 | 425 |
347 base::TimeDelta | 426 base::TimeDelta |
348 CompositorTimingHistory::BeginMainFrameQueueDurationCriticalEstimate() const { | 427 CompositorTimingHistory::BeginMainFrameQueueDurationCriticalEstimate() const { |
349 return begin_main_frame_queue_duration_critical_history_.Percentile( | 428 return begin_main_frame_queue_duration_critical_history_.Percentile( |
350 kBeginMainFrameQueueDurationCriticalEstimationPercentile); | 429 kBeginMainFrameQueueDurationCriticalEstimationPercentile); |
(...skipping 24 matching lines...) Expand all Loading... |
375 } | 454 } |
376 | 455 |
377 base::TimeDelta CompositorTimingHistory::ActivateDurationEstimate() const { | 456 base::TimeDelta CompositorTimingHistory::ActivateDurationEstimate() const { |
378 return activate_duration_history_.Percentile(kActivateEstimationPercentile); | 457 return activate_duration_history_.Percentile(kActivateEstimationPercentile); |
379 } | 458 } |
380 | 459 |
381 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const { | 460 base::TimeDelta CompositorTimingHistory::DrawDurationEstimate() const { |
382 return draw_duration_history_.Percentile(kDrawEstimationPercentile); | 461 return draw_duration_history_.Percentile(kDrawEstimationPercentile); |
383 } | 462 } |
384 | 463 |
| 464 void CompositorTimingHistory::WillBeginImplFrame( |
| 465 bool new_active_tree_is_likely) { |
| 466 // The check for whether a BeginMainFrame was sent anytime between two |
| 467 // BeginImplFrames protects us from not detecting a fast main thread that |
| 468 // does all it's work and goes idle in between BeginImplFrames. |
| 469 // For example, this may happen if an animation is being driven with |
| 470 // setInterval(17) or if input events just happen to arrive in the |
| 471 // middle of every frame. |
| 472 if (!new_active_tree_is_likely && !did_send_begin_main_frame_) { |
| 473 SetBeginMainFrameNeededContinuously(false); |
| 474 SetBeginMainFrameCommittingContinuously(false); |
| 475 } |
| 476 |
| 477 did_send_begin_main_frame_ = false; |
| 478 } |
| 479 |
| 480 void CompositorTimingHistory::WillFinishImplFrame(bool needs_redraw) { |
| 481 if (!needs_redraw) |
| 482 SetCompositorDrawingContinuously(false); |
| 483 } |
| 484 |
| 485 void CompositorTimingHistory::BeginImplFrameNotExpectedSoon() { |
| 486 SetBeginMainFrameNeededContinuously(false); |
| 487 SetBeginMainFrameCommittingContinuously(false); |
| 488 SetCompositorDrawingContinuously(false); |
| 489 } |
| 490 |
385 void CompositorTimingHistory::WillBeginMainFrame(bool on_critical_path) { | 491 void CompositorTimingHistory::WillBeginMainFrame(bool on_critical_path) { |
386 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); | 492 DCHECK_EQ(base::TimeTicks(), begin_main_frame_sent_time_); |
387 begin_main_frame_on_critical_path_ = on_critical_path; | 493 begin_main_frame_on_critical_path_ = on_critical_path; |
388 begin_main_frame_sent_time_ = Now(); | 494 begin_main_frame_sent_time_ = Now(); |
| 495 |
| 496 did_send_begin_main_frame_ = true; |
| 497 SetBeginMainFrameNeededContinuously(true); |
389 } | 498 } |
390 | 499 |
391 void CompositorTimingHistory::BeginMainFrameStarted( | 500 void CompositorTimingHistory::BeginMainFrameStarted( |
392 base::TimeTicks main_thread_start_time) { | 501 base::TimeTicks main_thread_start_time) { |
393 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); | 502 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); |
394 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); | 503 DCHECK_EQ(base::TimeTicks(), begin_main_frame_start_time_); |
395 begin_main_frame_start_time_ = main_thread_start_time; | 504 begin_main_frame_start_time_ = main_thread_start_time; |
396 } | 505 } |
397 | 506 |
398 void CompositorTimingHistory::BeginMainFrameAborted() { | 507 void CompositorTimingHistory::BeginMainFrameAborted() { |
399 DidCommit(); | 508 SetBeginMainFrameCommittingContinuously(false); |
| 509 DidBeginMainFrame(); |
400 } | 510 } |
401 | 511 |
402 void CompositorTimingHistory::DidCommit() { | 512 void CompositorTimingHistory::DidCommit() { |
| 513 SetBeginMainFrameCommittingContinuously(true); |
| 514 DidBeginMainFrame(); |
| 515 } |
| 516 |
| 517 void CompositorTimingHistory::DidBeginMainFrame() { |
403 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); | 518 DCHECK_NE(base::TimeTicks(), begin_main_frame_sent_time_); |
404 | 519 |
405 commit_time_ = Now(); | 520 begin_main_frame_end_time_ = Now(); |
406 | 521 |
407 // If the BeginMainFrame start time isn't know, assume it was immediate | 522 // If the BeginMainFrame start time isn't know, assume it was immediate |
408 // for scheduling purposes, but don't report it for UMA to avoid skewing | 523 // for scheduling purposes, but don't report it for UMA to avoid skewing |
409 // the results. | 524 // the results. |
410 bool begin_main_frame_start_time_is_valid = | 525 bool begin_main_frame_start_time_is_valid = |
411 !begin_main_frame_start_time_.is_null(); | 526 !begin_main_frame_start_time_.is_null(); |
412 if (!begin_main_frame_start_time_is_valid) | 527 if (!begin_main_frame_start_time_is_valid) |
413 begin_main_frame_start_time_ = begin_main_frame_sent_time_; | 528 begin_main_frame_start_time_ = begin_main_frame_sent_time_; |
414 | 529 |
415 base::TimeDelta begin_main_frame_sent_to_commit_duration = | 530 base::TimeDelta begin_main_frame_sent_to_commit_duration = |
416 commit_time_ - begin_main_frame_sent_time_; | 531 begin_main_frame_end_time_ - begin_main_frame_sent_time_; |
417 base::TimeDelta begin_main_frame_queue_duration = | 532 base::TimeDelta begin_main_frame_queue_duration = |
418 begin_main_frame_start_time_ - begin_main_frame_sent_time_; | 533 begin_main_frame_start_time_ - begin_main_frame_sent_time_; |
419 base::TimeDelta begin_main_frame_start_to_commit_duration = | 534 base::TimeDelta begin_main_frame_start_to_commit_duration = |
420 commit_time_ - begin_main_frame_start_time_; | 535 begin_main_frame_end_time_ - begin_main_frame_start_time_; |
421 | 536 |
422 // Before adding the new data point to the timing history, see what we would | 537 // Before adding the new data point to the timing history, see what we would |
423 // have predicted for this frame. This allows us to keep track of the accuracy | 538 // have predicted for this frame. This allows us to keep track of the accuracy |
424 // of our predictions. | 539 // of our predictions. |
425 base::TimeDelta begin_main_frame_sent_to_commit_estimate = | 540 base::TimeDelta begin_main_frame_sent_to_commit_estimate = |
426 BeginMainFrameToCommitDurationEstimate(); | 541 BeginMainFrameToCommitDurationEstimate(); |
427 uma_reporter_->AddBeginMainFrameToCommitDuration( | 542 uma_reporter_->AddBeginMainFrameToCommitDuration( |
428 begin_main_frame_sent_to_commit_duration, | 543 begin_main_frame_sent_to_commit_duration, |
429 begin_main_frame_sent_to_commit_estimate, enabled_); | 544 begin_main_frame_sent_to_commit_estimate, enabled_); |
430 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration( | 545 rendering_stats_instrumentation_->AddBeginMainFrameToCommitDuration( |
(...skipping 20 matching lines...) Expand all Loading... |
451 begin_main_frame_queue_duration_critical_history_.InsertSample( | 566 begin_main_frame_queue_duration_critical_history_.InsertSample( |
452 begin_main_frame_queue_duration); | 567 begin_main_frame_queue_duration); |
453 } else { | 568 } else { |
454 begin_main_frame_queue_duration_not_critical_history_.InsertSample( | 569 begin_main_frame_queue_duration_not_critical_history_.InsertSample( |
455 begin_main_frame_queue_duration); | 570 begin_main_frame_queue_duration); |
456 } | 571 } |
457 begin_main_frame_start_to_commit_duration_history_.InsertSample( | 572 begin_main_frame_start_to_commit_duration_history_.InsertSample( |
458 begin_main_frame_start_to_commit_duration); | 573 begin_main_frame_start_to_commit_duration); |
459 } | 574 } |
460 | 575 |
| 576 if (begin_main_frame_needed_continuously_) { |
| 577 if (!begin_main_frame_end_time_prev_.is_null()) { |
| 578 base::TimeDelta commit_interval = |
| 579 begin_main_frame_end_time_ - begin_main_frame_end_time_prev_; |
| 580 if (begin_main_frame_on_critical_path_) |
| 581 uma_reporter_->AddBeginMainFrameIntervalCritical(commit_interval); |
| 582 else |
| 583 uma_reporter_->AddBeginMainFrameIntervalNotCritical(commit_interval); |
| 584 } |
| 585 begin_main_frame_end_time_prev_ = begin_main_frame_end_time_; |
| 586 } |
| 587 |
461 begin_main_frame_sent_time_ = base::TimeTicks(); | 588 begin_main_frame_sent_time_ = base::TimeTicks(); |
462 begin_main_frame_start_time_ = base::TimeTicks(); | 589 begin_main_frame_start_time_ = base::TimeTicks(); |
463 } | 590 } |
464 | 591 |
465 void CompositorTimingHistory::WillPrepareTiles() { | 592 void CompositorTimingHistory::WillPrepareTiles() { |
466 DCHECK_EQ(base::TimeTicks(), start_prepare_tiles_time_); | 593 DCHECK_EQ(base::TimeTicks(), prepare_tiles_start_time_); |
467 start_prepare_tiles_time_ = Now(); | 594 prepare_tiles_start_time_ = Now(); |
468 } | 595 } |
469 | 596 |
470 void CompositorTimingHistory::DidPrepareTiles() { | 597 void CompositorTimingHistory::DidPrepareTiles() { |
471 DCHECK_NE(base::TimeTicks(), start_prepare_tiles_time_); | 598 DCHECK_NE(base::TimeTicks(), prepare_tiles_start_time_); |
472 | 599 |
473 base::TimeDelta prepare_tiles_duration = Now() - start_prepare_tiles_time_; | 600 base::TimeDelta prepare_tiles_duration = Now() - prepare_tiles_start_time_; |
474 uma_reporter_->AddPrepareTilesDuration( | 601 uma_reporter_->AddPrepareTilesDuration( |
475 prepare_tiles_duration, PrepareTilesDurationEstimate(), enabled_); | 602 prepare_tiles_duration, PrepareTilesDurationEstimate(), enabled_); |
476 if (enabled_) | 603 if (enabled_) |
477 prepare_tiles_duration_history_.InsertSample(prepare_tiles_duration); | 604 prepare_tiles_duration_history_.InsertSample(prepare_tiles_duration); |
478 | 605 |
479 start_prepare_tiles_time_ = base::TimeTicks(); | 606 prepare_tiles_start_time_ = base::TimeTicks(); |
480 } | 607 } |
481 | 608 |
482 void CompositorTimingHistory::ReadyToActivate() { | 609 void CompositorTimingHistory::ReadyToActivate() { |
483 // We only care about the first ready to activate signal | 610 // We only care about the first ready to activate signal |
484 // after a commit. | 611 // after a commit. |
485 if (commit_time_ == base::TimeTicks()) | 612 if (begin_main_frame_end_time_ == base::TimeTicks()) |
486 return; | 613 return; |
487 | 614 |
488 base::TimeDelta time_since_commit = Now() - commit_time_; | 615 base::TimeDelta time_since_commit = Now() - begin_main_frame_end_time_; |
489 | 616 |
490 // Before adding the new data point to the timing history, see what we would | 617 // Before adding the new data point to the timing history, see what we would |
491 // have predicted for this frame. This allows us to keep track of the accuracy | 618 // have predicted for this frame. This allows us to keep track of the accuracy |
492 // of our predictions. | 619 // of our predictions. |
493 | 620 |
494 base::TimeDelta commit_to_ready_to_activate_estimate = | 621 base::TimeDelta commit_to_ready_to_activate_estimate = |
495 CommitToReadyToActivateDurationEstimate(); | 622 CommitToReadyToActivateDurationEstimate(); |
496 uma_reporter_->AddCommitToReadyToActivateDuration( | 623 uma_reporter_->AddCommitToReadyToActivateDuration( |
497 time_since_commit, commit_to_ready_to_activate_estimate, enabled_); | 624 time_since_commit, commit_to_ready_to_activate_estimate, enabled_); |
498 rendering_stats_instrumentation_->AddCommitToActivateDuration( | 625 rendering_stats_instrumentation_->AddCommitToActivateDuration( |
499 time_since_commit, commit_to_ready_to_activate_estimate); | 626 time_since_commit, commit_to_ready_to_activate_estimate); |
500 | 627 |
501 if (enabled_) { | 628 if (enabled_) { |
502 commit_to_ready_to_activate_duration_history_.InsertSample( | 629 commit_to_ready_to_activate_duration_history_.InsertSample( |
503 time_since_commit); | 630 time_since_commit); |
504 } | 631 } |
505 | 632 |
506 commit_time_ = base::TimeTicks(); | 633 begin_main_frame_end_time_ = base::TimeTicks(); |
507 } | 634 } |
508 | 635 |
509 void CompositorTimingHistory::WillActivate() { | 636 void CompositorTimingHistory::WillActivate() { |
510 DCHECK_EQ(base::TimeTicks(), start_activate_time_); | 637 DCHECK_EQ(base::TimeTicks(), activate_start_time_); |
511 start_activate_time_ = Now(); | 638 activate_start_time_ = Now(); |
512 } | 639 } |
513 | 640 |
514 void CompositorTimingHistory::DidActivate() { | 641 void CompositorTimingHistory::DidActivate() { |
515 DCHECK_NE(base::TimeTicks(), start_activate_time_); | 642 DCHECK_NE(base::TimeTicks(), activate_start_time_); |
516 base::TimeDelta activate_duration = Now() - start_activate_time_; | 643 base::TimeDelta activate_duration = Now() - activate_start_time_; |
517 | 644 |
518 uma_reporter_->AddActivateDuration(activate_duration, | 645 uma_reporter_->AddActivateDuration(activate_duration, |
519 ActivateDurationEstimate(), enabled_); | 646 ActivateDurationEstimate(), enabled_); |
520 if (enabled_) | 647 if (enabled_) |
521 activate_duration_history_.InsertSample(activate_duration); | 648 activate_duration_history_.InsertSample(activate_duration); |
522 | 649 |
523 start_activate_time_ = base::TimeTicks(); | 650 activate_start_time_ = base::TimeTicks(); |
524 } | 651 } |
525 | 652 |
526 void CompositorTimingHistory::WillDraw() { | 653 void CompositorTimingHistory::WillDraw() { |
527 DCHECK_EQ(base::TimeTicks(), start_draw_time_); | 654 DCHECK_EQ(base::TimeTicks(), draw_start_time_); |
528 start_draw_time_ = Now(); | 655 draw_start_time_ = Now(); |
529 } | 656 } |
530 | 657 |
531 void CompositorTimingHistory::DidDraw() { | 658 void CompositorTimingHistory::DidDraw(bool used_new_active_tree) { |
532 DCHECK_NE(base::TimeTicks(), start_draw_time_); | 659 DCHECK_NE(base::TimeTicks(), draw_start_time_); |
533 base::TimeDelta draw_duration = Now() - start_draw_time_; | 660 base::TimeTicks draw_end_time = Now(); |
| 661 base::TimeDelta draw_duration = draw_end_time - draw_start_time_; |
534 | 662 |
535 // Before adding the new data point to the timing history, see what we would | 663 // Before adding the new data point to the timing history, see what we would |
536 // have predicted for this frame. This allows us to keep track of the accuracy | 664 // have predicted for this frame. This allows us to keep track of the accuracy |
537 // of our predictions. | 665 // of our predictions. |
538 base::TimeDelta draw_estimate = DrawDurationEstimate(); | 666 base::TimeDelta draw_estimate = DrawDurationEstimate(); |
539 rendering_stats_instrumentation_->AddDrawDuration(draw_duration, | 667 rendering_stats_instrumentation_->AddDrawDuration(draw_duration, |
540 draw_estimate); | 668 draw_estimate); |
541 | 669 |
542 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); | 670 uma_reporter_->AddDrawDuration(draw_duration, draw_estimate, enabled_); |
543 | 671 |
544 if (enabled_) { | 672 if (enabled_) { |
545 draw_duration_history_.InsertSample(draw_duration); | 673 draw_duration_history_.InsertSample(draw_duration); |
546 } | 674 } |
547 | 675 |
548 start_draw_time_ = base::TimeTicks(); | 676 SetCompositorDrawingContinuously(true); |
| 677 if (!draw_end_time_prev_.is_null()) { |
| 678 base::TimeDelta draw_interval = draw_end_time - draw_end_time_prev_; |
| 679 uma_reporter_->AddDrawInterval(draw_interval); |
| 680 } |
| 681 draw_end_time_prev_ = draw_end_time; |
| 682 |
| 683 if (begin_main_frame_committing_continuously_ && used_new_active_tree) { |
| 684 if (!new_active_tree_draw_end_time_prev_.is_null()) { |
| 685 base::TimeDelta draw_interval = |
| 686 draw_end_time - new_active_tree_draw_end_time_prev_; |
| 687 uma_reporter_->AddCommitInterval(draw_interval); |
| 688 } |
| 689 new_active_tree_draw_end_time_prev_ = draw_end_time; |
| 690 } |
| 691 |
| 692 draw_start_time_ = base::TimeTicks(); |
549 } | 693 } |
550 | 694 |
551 void CompositorTimingHistory::DidSwapBuffers() { | 695 void CompositorTimingHistory::DidSwapBuffers() { |
552 DCHECK_EQ(base::TimeTicks(), swap_start_time_); | 696 DCHECK_EQ(base::TimeTicks(), swap_start_time_); |
553 swap_start_time_ = Now(); | 697 swap_start_time_ = Now(); |
554 } | 698 } |
555 | 699 |
556 void CompositorTimingHistory::DidSwapBuffersComplete() { | 700 void CompositorTimingHistory::DidSwapBuffersComplete() { |
557 DCHECK_NE(base::TimeTicks(), swap_start_time_); | 701 DCHECK_NE(base::TimeTicks(), swap_start_time_); |
558 base::TimeDelta swap_to_ack_duration = Now() - swap_start_time_; | 702 base::TimeDelta swap_to_ack_duration = Now() - swap_start_time_; |
559 uma_reporter_->AddSwapToAckLatency(swap_to_ack_duration); | 703 uma_reporter_->AddSwapToAckLatency(swap_to_ack_duration); |
560 swap_start_time_ = base::TimeTicks(); | 704 swap_start_time_ = base::TimeTicks(); |
561 } | 705 } |
562 | 706 |
563 void CompositorTimingHistory::DidSwapBuffersReset() { | 707 void CompositorTimingHistory::DidSwapBuffersReset() { |
564 swap_start_time_ = base::TimeTicks(); | 708 swap_start_time_ = base::TimeTicks(); |
565 } | 709 } |
566 | 710 |
567 } // namespace cc | 711 } // namespace cc |
OLD | NEW |