diff --git a/src/Magnum/Math/Test/FunctionsBenchmark.cpp b/src/Magnum/Math/Test/FunctionsBenchmark.cpp index ec178322d..c8e87b4b4 100644 --- a/src/Magnum/Math/Test/FunctionsBenchmark.cpp +++ b/src/Magnum/Math/Test/FunctionsBenchmark.cpp @@ -45,6 +45,9 @@ struct FunctionsBenchmark: Corrade::TestSuite::Tester { void sqrtSseFromInverted(); void sqrtInvertedSse(); #endif + + void sinCosSeparate(); + void sinCosCombined(); }; FunctionsBenchmark::FunctionsBenchmark() { @@ -60,9 +63,14 @@ FunctionsBenchmark::FunctionsBenchmark() { &FunctionsBenchmark::sqrtInvertedSse, #endif }, 500); + + addBenchmarks({&FunctionsBenchmark::sinCosSeparate, + &FunctionsBenchmark::sinCosCombined}, 100); } typedef Math::Constants Constants; +typedef Math::Deg Deg; +typedef Math::Rad Rad; enum: std::size_t { Repeats = 100000 }; @@ -182,9 +190,32 @@ void FunctionsBenchmark::sqrtInvertedSse() { CORRADE_COMPARE_WITH(a, 1.0f, Corrade::TestSuite::Compare::around(0.0003f)); } - #endif +void FunctionsBenchmark::sinCosSeparate() { + Float sin{}, cos{}, a{}; + CORRADE_BENCHMARK(1000) { + sin += Math::sin(Rad(a)); + cos += Math::cos(Rad(a)); + a += 0.1f; + } + + CORRADE_COMPARE_AS(a, 10.0f, Corrade::TestSuite::Compare::Greater); +} + +void FunctionsBenchmark::sinCosCombined() { + Float sin{}, cos{}, a{}; + CORRADE_BENCHMARK(1000) { + auto sincos = Math::sincos(Rad(a)); + sin += sincos.first; + cos += sincos.second; + a += 0.1f; + } + + CORRADE_COMPARE_AS(a, 10.0f, Corrade::TestSuite::Compare::Greater); +} + + }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::FunctionsBenchmark) diff --git a/src/Magnum/Math/Test/FunctionsTest.cpp b/src/Magnum/Math/Test/FunctionsTest.cpp index f796a4c3b..815b75b65 100644 --- a/src/Magnum/Math/Test/FunctionsTest.cpp +++ b/src/Magnum/Math/Test/FunctionsTest.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include "Magnum/Math/Functions.h" @@ -85,9 +84,6 @@ struct FunctionsTest: Corrade::TestSuite::Tester { void trigonometric(); void trigonometricWithBase(); template void sincos(); - - void sinCosSeparateBenchmark(); - void sinCosCombinedBenchmark(); }; using namespace Literals; @@ -156,9 +152,6 @@ FunctionsTest::FunctionsTest() { &FunctionsTest::sincos, #endif }); - - addBenchmarks({&FunctionsTest::sinCosSeparateBenchmark, - &FunctionsTest::sinCosCombinedBenchmark}, 100); } void FunctionsTest::powIntegral() { @@ -605,29 +598,6 @@ template void FunctionsTest::sincos() { CORRADE_COMPARE(Math::sincos(Math::Deg(T(30.0))).second, T(0.866025403784438647l)); } -void FunctionsTest::sinCosSeparateBenchmark() { - Float sin{}, cos{}, a{}; - CORRADE_BENCHMARK(1000) { - sin += Math::sin(Rad(a)); - cos += Math::cos(Rad(a)); - a += 0.1f; - } - - CORRADE_COMPARE_AS(a, 10.0f, Corrade::TestSuite::Compare::Greater); -} - -void FunctionsTest::sinCosCombinedBenchmark() { - Float sin{}, cos{}, a{}; - CORRADE_BENCHMARK(1000) { - auto sincos = Math::sincos(Rad(a)); - sin += sincos.first; - cos += sincos.second; - a += 0.1f; - } - - CORRADE_COMPARE_AS(a, 10.0f, Corrade::TestSuite::Compare::Greater); -} - }}}} CORRADE_TEST_MAIN(Magnum::Math::Test::FunctionsTest)