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

Unified Diff: tests/MathTest.cpp

Issue 1616013003: de-proc sk_float_rsqrt (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: test both Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/opts/SkOpts_neon.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/MathTest.cpp
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 24e46f3097aea20d0f62277dd74aae2dd44eb5c2..de7ad1db78ed3a82c2e43aeaa87c3d11b6827a72 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -382,14 +382,15 @@ static void unittest_half(skiatest::Reporter* reporter) {
}
-static void test_rsqrt(skiatest::Reporter* reporter) {
+template <typename RSqrtFn>
+static void test_rsqrt(skiatest::Reporter* reporter, RSqrtFn rsqrt) {
const float maxRelativeError = 6.50196699e-4f;
// test close to 0 up to 1
float input = 0.000001f;
for (int i = 0; i < 1000; ++i) {
float exact = 1.0f/sk_float_sqrt(input);
- float estimate = sk_float_rsqrt(input);
+ float estimate = rsqrt(input);
float relativeError = sk_float_abs(exact - estimate)/exact;
REPORTER_ASSERT(reporter, relativeError <= maxRelativeError);
input += 0.001f;
@@ -399,7 +400,7 @@ static void test_rsqrt(skiatest::Reporter* reporter) {
input = 1.0f;
for (int i = 0; i < 1000; ++i) {
float exact = 1.0f/sk_float_sqrt(input);
- float estimate = sk_float_rsqrt(input);
+ float estimate = rsqrt(input);
float relativeError = sk_float_abs(exact - estimate)/exact;
REPORTER_ASSERT(reporter, relativeError <= maxRelativeError);
input += 0.01f;
@@ -409,7 +410,7 @@ static void test_rsqrt(skiatest::Reporter* reporter) {
input = 1000000.0f;
for (int i = 0; i < 100; ++i) {
float exact = 1.0f/sk_float_sqrt(input);
- float estimate = sk_float_rsqrt(input);
+ float estimate = rsqrt(input);
float relativeError = sk_float_abs(exact - estimate)/exact;
REPORTER_ASSERT(reporter, relativeError <= maxRelativeError);
input += 754326.f;
@@ -555,7 +556,8 @@ DEF_TEST(Math, reporter) {
unittest_fastfloat(reporter);
unittest_isfinite(reporter);
unittest_half(reporter);
- test_rsqrt(reporter);
+ test_rsqrt(reporter, sk_float_rsqrt);
+ test_rsqrt(reporter, sk_float_rsqrt_portable);
for (i = 0; i < 10000; i++) {
SkFixed numer = rand.nextS();
« no previous file with comments | « src/opts/SkOpts_neon.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698