| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 bool AlwaysReturn(bool result, const DownloadItem& item) { | 38 bool AlwaysReturn(bool result, const DownloadItem& item) { |
| 39 return result; | 39 return result; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // anonymous namespace | 42 } // anonymous namespace |
| 43 | 43 |
| 44 class DownloadQueryTest : public testing::Test { | 44 class DownloadQueryTest : public testing::Test { |
| 45 public: | 45 public: |
| 46 DownloadQueryTest() {} | 46 DownloadQueryTest() {} |
| 47 | 47 |
| 48 virtual ~DownloadQueryTest() {} | 48 ~DownloadQueryTest() override {} |
| 49 | 49 |
| 50 virtual void TearDown() { | 50 void TearDown() override { STLDeleteElements(&mocks_); } |
| 51 STLDeleteElements(&mocks_); | |
| 52 } | |
| 53 | 51 |
| 54 void CreateMocks(int count) { | 52 void CreateMocks(int count) { |
| 55 for (int i = 0; i < count; ++i) { | 53 for (int i = 0; i < count; ++i) { |
| 56 mocks_.push_back(new content::MockDownloadItem()); | 54 mocks_.push_back(new content::MockDownloadItem()); |
| 57 EXPECT_CALL(mock(mocks_.size() - 1), GetId()).WillRepeatedly(Return( | 55 EXPECT_CALL(mock(mocks_.size() - 1), GetId()).WillRepeatedly(Return( |
| 58 mocks_.size() - 1)); | 56 mocks_.size() - 1)); |
| 59 } | 57 } |
| 60 } | 58 } |
| 61 | 59 |
| 62 content::MockDownloadItem& mock(int index) { return *mocks_[index]; } | 60 content::MockDownloadItem& mock(int index) { return *mocks_[index]; } |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 base::Time start = base::Time::Now(); | 603 base::Time start = base::Time::Now(); |
| 606 Search(); | 604 Search(); |
| 607 base::Time end = base::Time::Now(); | 605 base::Time end = base::Time::Now(); |
| 608 double nanos = (end - start).InMillisecondsF() * 1000.0 * 1000.0; | 606 double nanos = (end - start).InMillisecondsF() * 1000.0 * 1000.0; |
| 609 double nanos_per_item = nanos / static_cast<double>(kNumItems); | 607 double nanos_per_item = nanos / static_cast<double>(kNumItems); |
| 610 double nanos_per_item_per_filter = nanos_per_item | 608 double nanos_per_item_per_filter = nanos_per_item |
| 611 / static_cast<double>(kNumFilters); | 609 / static_cast<double>(kNumFilters); |
| 612 std::cout << "Search took " << nanos_per_item_per_filter | 610 std::cout << "Search took " << nanos_per_item_per_filter |
| 613 << " nanoseconds per item per filter.\n"; | 611 << " nanoseconds per item per filter.\n"; |
| 614 } | 612 } |
| OLD | NEW |