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 "cc/base/lap_timer.h" | 5 #include "cc/base/lap_timer.h" |
6 #include "cc/base/rtree.h" | 6 #include "cc/base/rtree.h" |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "testing/perf/perf_test.h" | 9 #include "testing/perf/perf_test.h" |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 gfx::Rect(-10, -10, 1, 1), gfx::Rect(0, 0, 1000, 1000), | 43 gfx::Rect(-10, -10, 1, 1), gfx::Rect(0, 0, 1000, 1000), |
44 gfx::Rect(large_query - 2, large_query - 2, 1, 1)}; | 44 gfx::Rect(large_query - 2, large_query - 2, 1, 1)}; |
45 size_t query_index = 0; | 45 size_t query_index = 0; |
46 | 46 |
47 std::vector<gfx::Rect> rects = BuildRects(rect_count); | 47 std::vector<gfx::Rect> rects = BuildRects(rect_count); |
48 RTree rtree; | 48 RTree rtree; |
49 rtree.Build(rects); | 49 rtree.Build(rects); |
50 | 50 |
51 timer_.Reset(); | 51 timer_.Reset(); |
52 do { | 52 do { |
53 std::vector<size_t> results; | 53 rtree.Search(queries[query_index]); |
54 rtree.Search(queries[query_index], &results); | |
55 query_index = (query_index + 1) % queries.size(); | 54 query_index = (query_index + 1) % queries.size(); |
56 timer_.NextLap(); | 55 timer_.NextLap(); |
57 } while (!timer_.HasTimeLimitExpired()); | 56 } while (!timer_.HasTimeLimitExpired()); |
58 | 57 |
59 perf_test::PrintResult("rtree_search", "", test_name, | 58 perf_test::PrintResult("rtree_search", "", test_name, |
60 timer_.LapsPerSecond(), "runs/s", true); | 59 timer_.LapsPerSecond(), "runs/s", true); |
61 } | 60 } |
62 | 61 |
63 std::vector<gfx::Rect> BuildRects(int count) { | 62 std::vector<gfx::Rect> BuildRects(int count) { |
64 std::vector<gfx::Rect> result; | 63 std::vector<gfx::Rect> result; |
(...skipping 23 matching lines...) Expand all Loading... |
88 | 87 |
89 TEST_F(RTreePerfTest, Search) { | 88 TEST_F(RTreePerfTest, Search) { |
90 RunSearchTest("100", 100); | 89 RunSearchTest("100", 100); |
91 RunSearchTest("1000", 1000); | 90 RunSearchTest("1000", 1000); |
92 RunSearchTest("10000", 10000); | 91 RunSearchTest("10000", 10000); |
93 RunSearchTest("100000", 100000); | 92 RunSearchTest("100000", 100000); |
94 } | 93 } |
95 | 94 |
96 } // namespace | 95 } // namespace |
97 } // namespace cc | 96 } // namespace cc |
OLD | NEW |