| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "perf_test_helpers.h" | 5 #include "perf_test_helpers.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/perf/perf_test.h" | 11 #include "testing/perf/perf_test.h" |
| 12 | 12 |
| 13 namespace tracing { | 13 namespace tracing { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 void PrintPerfTestMs(const std::string& name, int64_t value) { | 17 void PrintPerfTestMs(const std::string& name, int64_t value) { |
| 18 CHECK(::testing::UnitTest::GetInstance() != nullptr) << "Must be GTest."; | 18 // Must be GTest. |
| 19 CHECK(::testing::UnitTest::GetInstance() != nullptr); |
| 19 const ::testing::TestInfo* test_info = | 20 const ::testing::TestInfo* test_info = |
| 20 ::testing::UnitTest::GetInstance()->current_test_info(); | 21 ::testing::UnitTest::GetInstance()->current_test_info(); |
| 21 CHECK(test_info != nullptr) << "Must be GTest."; | 22 // Must be GTest. |
| 23 CHECK(test_info != nullptr); |
| 22 | 24 |
| 23 perf_test::PrintResult(test_info->test_case_name(), | 25 perf_test::PrintResult(test_info->test_case_name(), |
| 24 std::string(".") + test_info->name(), | 26 std::string(".") + test_info->name(), |
| 25 name, static_cast<double>(value), "ms", true); | 27 name, static_cast<double>(value), "ms", true); |
| 26 } | 28 } |
| 27 | 29 |
| 28 } // namespace | 30 } // namespace |
| 29 | 31 |
| 30 ScopedStopwatch::ScopedStopwatch(const std::string& name) : name_(name) { | 32 ScopedStopwatch::ScopedStopwatch(const std::string& name) : name_(name) { |
| 31 begin_= base::TimeTicks::Now(); | 33 begin_= base::TimeTicks::Now(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 48 } | 50 } |
| 49 | 51 |
| 50 IterableStopwatch::~IterableStopwatch() { | 52 IterableStopwatch::~IterableStopwatch() { |
| 51 CHECK(!laps_.empty()); | 53 CHECK(!laps_.empty()); |
| 52 std::sort(laps_.begin(), laps_.end()); | 54 std::sort(laps_.begin(), laps_.end()); |
| 53 int64_t median = laps_.at(laps_.size() / 2); | 55 int64_t median = laps_.at(laps_.size() / 2); |
| 54 PrintPerfTestMs(name_, median); | 56 PrintPerfTestMs(name_, median); |
| 55 } | 57 } |
| 56 | 58 |
| 57 } // namespace tracing | 59 } // namespace tracing |
| OLD | NEW |