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

Side by Side Diff: bench/PathBench.cpp

Issue 111283007: Cap memory usage in path_create bench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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 | no next file » | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkBenchmark.h" 8 #include "SkBenchmark.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 PathCreateBench() { 320 PathCreateBench() {
321 } 321 }
322 322
323 protected: 323 protected:
324 virtual const char* onGetName() SK_OVERRIDE { 324 virtual const char* onGetName() SK_OVERRIDE {
325 return "path_create"; 325 return "path_create";
326 } 326 }
327 327
328 virtual void onPreDraw() SK_OVERRIDE { 328 virtual void onPreDraw() SK_OVERRIDE {
329 this->createData(10, 100); 329 this->createData(10, 100);
330 fPaths.reset(kPathCnt);
331 } 330 }
332 331
333 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE { 332 virtual void onDraw(const int loops, SkCanvas*) SK_OVERRIDE {
334 for (int i = 0; i < loops; ++i) { 333 for (int i = 0; i < loops; ++i) {
335 this->makePath(&fPaths[i & (kPathCnt - 1)]); 334 if (i % 1000 == 0) {
335 fPath.reset(); // PathRef memory can grow without bound otherwi se.
336 }
337 this->makePath(&fPath);
336 } 338 }
337 this->restartMakingPaths(); 339 this->restartMakingPaths();
338 } 340 }
339 341
340 virtual void onPostDraw() SK_OVERRIDE { 342 virtual void onPostDraw() SK_OVERRIDE {
341 this->finishedMakingPaths(); 343 this->finishedMakingPaths();
342 fPaths.reset(0);
343 } 344 }
344 345
345 private: 346 private:
346 enum { 347 SkPath fPath;
347 // must be a pow 2
348 kPathCnt = 1 << 5,
349 };
350 SkAutoTArray<SkPath> fPaths;
351 348
352 typedef RandomPathBench INHERITED; 349 typedef RandomPathBench INHERITED;
353 }; 350 };
354 351
355 class PathCopyBench : public RandomPathBench { 352 class PathCopyBench : public RandomPathBench {
356 public: 353 public:
357 PathCopyBench() { 354 PathCopyBench() {
358 } 355 }
359 356
360 protected: 357 protected:
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 DEF_BENCH( return new ArbRoundRectBench(true); ) 1037 DEF_BENCH( return new ArbRoundRectBench(true); )
1041 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Rect_Type); ) 1038 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Rect_Type); )
1042 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k RoundRect_Type); ) 1039 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k RoundRect_Type); )
1043 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); ) 1040 DEF_BENCH( return new ConservativelyContainsBench(ConservativelyContainsBench::k Oval_Type); )
1044 1041
1045 DEF_BENCH( return new ConicBench_Chop5() ) 1042 DEF_BENCH( return new ConicBench_Chop5() )
1046 DEF_BENCH( return new ConicBench_ChopHalf() ) 1043 DEF_BENCH( return new ConicBench_ChopHalf() )
1047 DEF_BENCH( return new ConicBench_ComputeError() ) 1044 DEF_BENCH( return new ConicBench_ComputeError() )
1048 DEF_BENCH( return new ConicBench_asQuadTol() ) 1045 DEF_BENCH( return new ConicBench_asQuadTol() )
1049 DEF_BENCH( return new ConicBench_quadPow2() ) 1046 DEF_BENCH( return new ConicBench_quadPow2() )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698