Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: bench/GeometryBench.cpp

Issue 646863002: faster SkRect::sort (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | include/core/SkRect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 count += r.intersect(fRects[0], fRects[i]); 90 count += r.intersect(fRects[0], fRects[i]);
91 } 91 }
92 this->virtualCallToFoilOptimizers(count); 92 this->virtualCallToFoilOptimizers(count);
93 } 93 }
94 } 94 }
95 }; 95 };
96 96
97 class GeoRectBench_Intersects : public GeoRectBench { 97 class GeoRectBench_Intersects : public GeoRectBench {
98 public: 98 public:
99 GeoRectBench_Intersects() : GeoRectBench("rect_Intersects") {} 99 GeoRectBench_Intersects() : GeoRectBench("rect_Intersects") {}
100 100
101 protected: 101 protected:
102 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 102 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
103 for (int outer = 0; outer < loops; ++outer) { 103 for (int outer = 0; outer < loops; ++outer) {
104 int count = 0; 104 int count = 0;
105 for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) { 105 for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
106 count += SkRect::Intersects(fRects[0], fRects[i]); 106 count += SkRect::Intersects(fRects[0], fRects[i]);
107 } 107 }
108 this->virtualCallToFoilOptimizers(count); 108 this->virtualCallToFoilOptimizers(count);
109 } 109 }
110 } 110 }
111 }; 111 };
112 112
113 class GeoRectBench_sort : public GeoRectBench {
114 public:
115 GeoRectBench_sort() : GeoRectBench("rect_sort") {}
116
117 protected:
118 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
119 for (int outer = 0; outer < loops; ++outer) {
120 for (size_t i = 0; i < SK_ARRAY_COUNT(fRects); ++i) {
121 fRects[i].sort();
122 }
123 }
124 }
125 };
126
113 DEF_BENCH( return new GeoRectBench_intersect; ) 127 DEF_BENCH( return new GeoRectBench_intersect; )
114 DEF_BENCH( return new GeoRectBench_intersect_rect; ) 128 DEF_BENCH( return new GeoRectBench_intersect_rect; )
115 DEF_BENCH( return new GeoRectBench_Intersects; ) 129 DEF_BENCH( return new GeoRectBench_Intersects; )
130
131 DEF_BENCH( return new GeoRectBench_sort; )
OLDNEW
« no previous file with comments | « no previous file | include/core/SkRect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698