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

Side by Side Diff: bench/MathBench.cpp

Issue 1510683002: Add sk_careful_memcpy to catch undefined behavior in memcpy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: two more Created 5 years 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 | gyp/common_conditions.gypi » ('j') | include/core/SkTArray.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkMatrix.h" 10 #include "SkMatrix.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 for (int i = 0; i < count; ++i) { 119 for (int i = 0; i < count; ++i) {
120 dst[i] = 1.0f / sk_float_sqrt(src[i]); 120 dst[i] = 1.0f / sk_float_sqrt(src[i]);
121 } 121 }
122 } 122 }
123 private: 123 private:
124 typedef MathBench INHERITED; 124 typedef MathBench INHERITED;
125 }; 125 };
126 126
127 static inline float SkFastInvSqrt(float x) { 127 static inline float SkFastInvSqrt(float x) {
128 float xhalf = 0.5f*x; 128 float xhalf = 0.5f*x;
129 int i = *SkTCast<int*>(&x); 129 uint32_t i = *SkTCast<uint32_t*>(&x);
130 i = 0x5f3759df - (i>>1); 130 i = 0x5f3759df - (i>>1);
131 x = *SkTCast<float*>(&i); 131 x = *SkTCast<float*>(&i);
132 x = x*(1.5f-xhalf*x*x); 132 x = x*(1.5f-xhalf*x*x);
133 // x = x*(1.5f-xhalf*x*x); // this line takes err from 10^-3 to 10^-6 133 // x = x*(1.5f-xhalf*x*x); // this line takes err from 10^-3 to 10^-6
134 return x; 134 return x;
135 } 135 }
136 136
137 class FastISqrtMathBench : public MathBench { 137 class FastISqrtMathBench : public MathBench {
138 public: 138 public:
139 FastISqrtMathBench() : INHERITED("fastIsqrt") {} 139 FastISqrtMathBench() : INHERITED("fastIsqrt") {}
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 599
600 DEF_BENCH( return new FloorBench(false); ) 600 DEF_BENCH( return new FloorBench(false); )
601 DEF_BENCH( return new FloorBench(true); ) 601 DEF_BENCH( return new FloorBench(true); )
602 602
603 DEF_BENCH( return new CLZBench(false); ) 603 DEF_BENCH( return new CLZBench(false); )
604 DEF_BENCH( return new CLZBench(true); ) 604 DEF_BENCH( return new CLZBench(true); )
605 605
606 DEF_BENCH( return new NormalizeBench(); ) 606 DEF_BENCH( return new NormalizeBench(); )
607 607
608 DEF_BENCH( return new FixedMathBench(); ) 608 DEF_BENCH( return new FixedMathBench(); )
OLDNEW
« no previous file with comments | « no previous file | gyp/common_conditions.gypi » ('j') | include/core/SkTArray.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698