summaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-04-11 17:02:20 -0700
committerElliott Hughes <enh@google.com>2014-04-14 14:35:47 -0700
commit02c78a386739a8a2b3007efeb00a9ca04132100a (patch)
tree6679bef40da8b7fbe6b3c5a479eb5c2e4e035708 /benchmarks
parent055890686636faddbb6d5d407c67f5dcc53ac865 (diff)
downloadbionic-02c78a386739a8a2b3007efeb00a9ca04132100a.zip
bionic-02c78a386739a8a2b3007efeb00a9ca04132100a.tar.gz
bionic-02c78a386739a8a2b3007efeb00a9ca04132100a.tar.bz2
Reimplement isinf/isnan/fpclassify.
Also move isinf and isnan into libc like everyone else. Also move fpclassify to libc like the BSDs (but unlike glibc). We need this to be able to upgrade our float/double/long double parsing to gdtoa. Also add some missing aliases. We now have all of: isnan, __isnan, isnanf, __isnanf, isnanl, __isnanl, isinf, __isinf, isinff, __isinff, isinfl, __isinfl, __fpclassify, __fpclassifyd, __fpclassifyf, __fpclassifyl. Bug: 13469877 Change-Id: I407ffbac06c765a6c5fffda8106c37d7db04f27d
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/math_benchmark.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/benchmarks/math_benchmark.cpp b/benchmarks/math_benchmark.cpp
index a8c1cfa..3602de4 100644
--- a/benchmarks/math_benchmark.cpp
+++ b/benchmarks/math_benchmark.cpp
@@ -60,3 +60,112 @@ static void BM_math_logb(int iters) {
StopBenchmarkTiming();
}
BENCHMARK(BM_math_logb);
+
+static void BM_math_isinf_NORMAL(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = 1234.0; // FP_NORMAL
+ for (int i = 0; i < iters; ++i) {
+ d += (isinf)(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_isinf_NORMAL);
+
+static void BM_math_isinf_NAN(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = nan(""); // FP_NAN
+ for (int i = 0; i < iters; ++i) {
+ d += (isinf)(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_isinf_NAN);
+
+static void BM_math_isinf_INFINITE(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = HUGE_VAL; // FP_INFINITE
+ for (int i = 0; i < iters; ++i) {
+ d += (isinf)(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_isinf_INFINITE);
+
+static void BM_math_isinf_ZERO(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = 0.0; // FP_ZERO
+ for (int i = 0; i < iters; ++i) {
+ d += (isinf)(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_isinf_ZERO);
+
+
+
+
+
+
+static void BM_math_fpclassify_NORMAL(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = 1234.0; // FP_NORMAL
+ for (int i = 0; i < iters; ++i) {
+ d += fpclassify(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_fpclassify_NORMAL);
+
+static void BM_math_fpclassify_NAN(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = nan(""); // FP_NAN
+ for (int i = 0; i < iters; ++i) {
+ d += fpclassify(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_fpclassify_NAN);
+
+static void BM_math_fpclassify_INFINITE(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = HUGE_VAL; // FP_INFINITE
+ for (int i = 0; i < iters; ++i) {
+ d += fpclassify(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_fpclassify_INFINITE);
+
+static void BM_math_fpclassify_ZERO(int iters) {
+ StartBenchmarkTiming();
+
+ d = 0.0;
+ v = 0.0; // FP_ZERO
+ for (int i = 0; i < iters; ++i) {
+ d += fpclassify(v);
+ }
+
+ StopBenchmarkTiming();
+}
+BENCHMARK(BM_math_fpclassify_ZERO);