| 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/resources/task_graph_runner.h" | 5 #include "cc/resources/task_graph_runner.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "cc/base/completion_event.h" | 11 #include "cc/base/completion_event.h" |
| 12 #include "cc/debug/lap_timer.h" | 12 #include "cc/debug/lap_timer.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/perf/perf_test.h" | 14 #include "testing/perf/perf_test.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 static const int kTimeLimitMillis = 2000; | 19 static const int kTimeLimitMillis = 2000; |
| 20 static const int kWarmupRuns = 5; | 20 static const int kWarmupRuns = 5; |
| 21 static const int kTimeCheckInterval = 10; | 21 static const int kTimeCheckInterval = 10; |
| 22 | 22 |
| 23 class PerfTaskImpl : public Task { | 23 class PerfTaskImpl : public Task { |
| 24 public: | 24 public: |
| 25 typedef std::vector<scoped_refptr<PerfTaskImpl> > Vector; | 25 typedef std::vector<scoped_refptr<PerfTaskImpl> > Vector; |
| 26 | 26 |
| 27 PerfTaskImpl() {} | 27 PerfTaskImpl() {} |
| 28 | 28 |
| 29 // Overridden from Task: | 29 // Overridden from Task: |
| 30 virtual void RunOnWorkerThread() OVERRIDE {} | 30 virtual void RunOnWorkerThread() override {} |
| 31 | 31 |
| 32 void Reset() { did_run_ = false; } | 32 void Reset() { did_run_ = false; } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 virtual ~PerfTaskImpl() {} | 35 virtual ~PerfTaskImpl() {} |
| 36 | 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(PerfTaskImpl); | 37 DISALLOW_COPY_AND_ASSIGN(PerfTaskImpl); |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class TaskGraphRunnerPerfTest : public testing::Test { | 40 class TaskGraphRunnerPerfTest : public testing::Test { |
| 41 public: | 41 public: |
| 42 TaskGraphRunnerPerfTest() | 42 TaskGraphRunnerPerfTest() |
| 43 : timer_(kWarmupRuns, | 43 : timer_(kWarmupRuns, |
| 44 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 44 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 45 kTimeCheckInterval) {} | 45 kTimeCheckInterval) {} |
| 46 | 46 |
| 47 // Overridden from testing::Test: | 47 // Overridden from testing::Test: |
| 48 virtual void SetUp() OVERRIDE { | 48 virtual void SetUp() override { |
| 49 task_graph_runner_ = make_scoped_ptr(new TaskGraphRunner); | 49 task_graph_runner_ = make_scoped_ptr(new TaskGraphRunner); |
| 50 namespace_token_ = task_graph_runner_->GetNamespaceToken(); | 50 namespace_token_ = task_graph_runner_->GetNamespaceToken(); |
| 51 } | 51 } |
| 52 virtual void TearDown() OVERRIDE { task_graph_runner_ = nullptr; } | 52 virtual void TearDown() override { task_graph_runner_ = nullptr; } |
| 53 | 53 |
| 54 void AfterTest(const std::string& test_name) { | 54 void AfterTest(const std::string& test_name) { |
| 55 // Format matches chrome/test/perf/perf_test.h:PrintResult | 55 // Format matches chrome/test/perf/perf_test.h:PrintResult |
| 56 printf( | 56 printf( |
| 57 "*RESULT %s: %.2f runs/s\n", test_name.c_str(), timer_.LapsPerSecond()); | 57 "*RESULT %s: %.2f runs/s\n", test_name.c_str(), timer_.LapsPerSecond()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void RunBuildTaskGraphTest(const std::string& test_name, | 60 void RunBuildTaskGraphTest(const std::string& test_name, |
| 61 int num_top_level_tasks, | 61 int num_top_level_tasks, |
| 62 int num_tasks, | 62 int num_tasks, |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); | 309 RunScheduleAndExecuteTasksTest("0_1_0", 0, 1, 0); |
| 310 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); | 310 RunScheduleAndExecuteTasksTest("0_32_0", 0, 32, 0); |
| 311 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); | 311 RunScheduleAndExecuteTasksTest("2_1_0", 2, 1, 0); |
| 312 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); | 312 RunScheduleAndExecuteTasksTest("2_32_0", 2, 32, 0); |
| 313 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); | 313 RunScheduleAndExecuteTasksTest("2_1_1", 2, 1, 1); |
| 314 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); | 314 RunScheduleAndExecuteTasksTest("2_32_1", 2, 32, 1); |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace | 317 } // namespace |
| 318 } // namespace cc | 318 } // namespace cc |
| OLD | NEW |