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

Side by Side Diff: bench/GrMemoryPoolBench.cpp

Issue 1846773002: Make SkRandom::next[US]Fixed1 private; update documentation for SkRandom::nextSScalar1. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 8 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/utils/SkRandom.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 2012 Google Inc. 2 * Copyright 2012 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 "SkTypes.h" 8 #include "SkTypes.h"
9 9
10 // This tests a Gr class 10 // This tests a Gr class
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 return "grmemorypool_stack"; 43 return "grmemorypool_stack";
44 } 44 }
45 45
46 void onDraw(int loops, SkCanvas*) override { 46 void onDraw(int loops, SkCanvas*) override {
47 SkRandom r; 47 SkRandom r;
48 enum { 48 enum {
49 kMaxObjects = 4 * (1 << 10), 49 kMaxObjects = 4 * (1 << 10),
50 }; 50 };
51 A* objects[kMaxObjects]; 51 A* objects[kMaxObjects];
52 52
53 // We delete if a random [-1, 1] fixed pt is < the thresh. Otherwise, 53 // We delete if a random number [-1, 1] is < the thresh. Otherwise,
54 // we allocate. We start allocate-biased and ping-pong to delete-biased 54 // we allocate. We start allocate-biased and ping-pong to delete-biased
55 SkFixed delThresh = -SK_FixedHalf; 55 SkScalar delThresh = -SK_ScalarHalf;
56 const int kSwitchThreshPeriod = loops / (2 * kMaxObjects); 56 const int kSwitchThreshPeriod = loops / (2 * kMaxObjects);
57 int s = 0; 57 int s = 0;
58 58
59 int count = 0; 59 int count = 0;
60 for (int i = 0; i < loops; i++, ++s) { 60 for (int i = 0; i < loops; i++, ++s) {
61 if (kSwitchThreshPeriod == s) { 61 if (kSwitchThreshPeriod == s) {
62 delThresh = -delThresh; 62 delThresh = -delThresh;
63 s = 0; 63 s = 0;
64 } 64 }
65 SkFixed del = r.nextSFixed1(); 65 SkScalar del = r.nextSScalar1();
66 if (count && 66 if (count &&
67 (kMaxObjects == count || del < delThresh)) { 67 (kMaxObjects == count || del < delThresh)) {
68 delete objects[count-1]; 68 delete objects[count-1];
69 --count; 69 --count;
70 } else { 70 } else {
71 objects[count] = new A; 71 objects[count] = new A;
72 ++count; 72 ++count;
73 } 73 }
74 } 74 }
75 for (int i = 0; i < count; ++i) { 75 for (int i = 0; i < count; ++i) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 typedef Benchmark INHERITED; 171 typedef Benchmark INHERITED;
172 }; 172 };
173 173
174 /////////////////////////////////////////////////////////////////////////////// 174 ///////////////////////////////////////////////////////////////////////////////
175 175
176 DEF_BENCH( return new GrMemoryPoolBenchStack(); ) 176 DEF_BENCH( return new GrMemoryPoolBenchStack(); )
177 DEF_BENCH( return new GrMemoryPoolBenchRandom(); ) 177 DEF_BENCH( return new GrMemoryPoolBenchRandom(); )
178 DEF_BENCH( return new GrMemoryPoolBenchQueue(); ) 178 DEF_BENCH( return new GrMemoryPoolBenchQueue(); )
179 179
180 #endif 180 #endif
OLDNEW
« no previous file with comments | « no previous file | include/utils/SkRandom.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698