| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 kPaintHeavy = 1 << 3 | 92 kPaintHeavy = 1 << 3 |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 const int kWebGLCanvasWidth = 10; | 95 const int kWebGLCanvasWidth = 10; |
| 96 const int kNumFrames = 80; | 96 const int kNumFrames = 80; |
| 97 const int kInputsPerFrame = 16; | 97 const int kInputsPerFrame = 16; |
| 98 // Magic number to identify certain glClear events. | 98 // Magic number to identify certain glClear events. |
| 99 const int kClearColorGreen = 137; | 99 const int kClearColorGreen = 137; |
| 100 const int kMouseY = 5; | 100 const int kMouseY = 5; |
| 101 | 101 |
| 102 // Don't analyze begin frames that may be inaccurate. Latencies can be as high | 102 // Don't analyze start frames that may be inaccurate. Latencies can be as high |
| 103 // as 5 frames or so, so skip the first 6 frames to get more accurate results. | 103 // as 5 frames or so, so skip the first 6 frames to get more accurate results. |
| 104 const int kIgnoreBeginFrames = 6; | 104 const int kIgnoreStartFrames = 6; |
| 105 // Don't analyze end frames that may be inaccurate. | 105 // Don't analyze end frames that may be inaccurate. |
| 106 const int kIgnoreEndFrames = 4; | 106 const int kIgnoreEndFrames = 4; |
| 107 // Minimum frames to produce an answer. | 107 // Minimum frames to produce an answer. |
| 108 const int kMinimumFramesForAnalysis = 5; | 108 const int kMinimumFramesForAnalysis = 5; |
| 109 | 109 |
| 110 class LatencyTest | 110 class LatencyTest |
| 111 : public BrowserPerfTest, | 111 : public BrowserPerfTest, |
| 112 public ::testing::WithParamInterface<int> { | 112 public ::testing::WithParamInterface<int> { |
| 113 public: | 113 public: |
| 114 explicit LatencyTest(LatencyTestMode mode) : | 114 explicit LatencyTest(LatencyTestMode mode) : |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 std::vector<double> latencies; | 471 std::vector<double> latencies; |
| 472 printf("Measured latency (in number of frames) for each frame:\n"); | 472 printf("Measured latency (in number of frames) for each frame:\n"); |
| 473 for (size_t i = 0; i < events.size(); ++i) { | 473 for (size_t i = 0; i < events.size(); ++i) { |
| 474 if (query_end_swaps_.Evaluate(*events[i])) { | 474 if (query_end_swaps_.Evaluate(*events[i])) { |
| 475 size_t end_swap_pos = i; | 475 size_t end_swap_pos = i; |
| 476 | 476 |
| 477 // Compositor context swap buffers. | 477 // Compositor context swap buffers. |
| 478 ++swap_count; | 478 ++swap_count; |
| 479 // Don't analyze first few swaps, because they are filling the rendering | 479 // Don't analyze first few swaps, because they are filling the rendering |
| 480 // pipeline and may be unstable. | 480 // pipeline and may be unstable. |
| 481 if (swap_count > kIgnoreBeginFrames) { | 481 if (swap_count > kIgnoreStartFrames) { |
| 482 // First, find the beginning of this swap. | 482 // First, find the beginning of this swap. |
| 483 size_t begin_swap_pos = 0; | 483 size_t begin_swap_pos = 0; |
| 484 EXPECT_TRUE(FindLastOf(events, query_begin_swaps_, end_swap_pos, | 484 EXPECT_TRUE(FindLastOf(events, query_begin_swaps_, end_swap_pos, |
| 485 &begin_swap_pos)); | 485 &begin_swap_pos)); |
| 486 | 486 |
| 487 int mouse_x = 0; | 487 int mouse_x = 0; |
| 488 if (use_gpu_) { | 488 if (use_gpu_) { |
| 489 // Trace backwards through the events to find the input event that | 489 // Trace backwards through the events to find the input event that |
| 490 // matches the glClear that was presented by this SwapBuffers. | 490 // matches the glClear that was presented by this SwapBuffers. |
| 491 | 491 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 kInputHeavy | kInputDirty | kRafHeavy, \ | 748 kInputHeavy | kInputDirty | kRafHeavy, \ |
| 749 kInputHeavy | kInputDirty | kRafHeavy | kPaintHeavy, \ | 749 kInputHeavy | kInputDirty | kRafHeavy | kPaintHeavy, \ |
| 750 kInputDirty | kPaintHeavy, \ | 750 kInputDirty | kPaintHeavy, \ |
| 751 kInputDirty | kRafHeavy | kPaintHeavy) | 751 kInputDirty | kRafHeavy | kPaintHeavy) |
| 752 | 752 |
| 753 INSTANTIATE_TEST_CASE_P(, LatencyTestWebGL, LATENCY_SUITE_MODES()); | 753 INSTANTIATE_TEST_CASE_P(, LatencyTestWebGL, LATENCY_SUITE_MODES()); |
| 754 INSTANTIATE_TEST_CASE_P(, LatencyTestWebGLThread, LATENCY_SUITE_MODES()); | 754 INSTANTIATE_TEST_CASE_P(, LatencyTestWebGLThread, LATENCY_SUITE_MODES()); |
| 755 INSTANTIATE_TEST_CASE_P(, LatencyTestSW, LATENCY_SUITE_MODES()); | 755 INSTANTIATE_TEST_CASE_P(, LatencyTestSW, LATENCY_SUITE_MODES()); |
| 756 | 756 |
| 757 } // namespace | 757 } // namespace |
| OLD | NEW |