diff --git a/readme.txt b/readme.txt index 99ad989d..c3993d72 100644 --- a/readme.txt +++ b/readme.txt @@ -79,6 +79,7 @@ Improvements: - Optimized bitfieldReverse and bitCount functions - Optimized matrix-vector multiple performance with Cuda #257, #258 - Reduced integer type redifinitions #233 +- Rewrite of GTX_fast_trigonometry #264 #265 Fixes: - Fixed std::nextafter not supported with C++11 on Android #217 diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index c45007b8..9a18db53 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -10,28 +10,151 @@ #include #include #include +#include +#include -int test_fastSin() +namespace fastCos { - int Error(0); - - float DiffMax = 0.0f; - for(std::size_t i = 0; i < 10000; ++i) + int perf() { - float angle = glm::pi() * 2.0f / static_cast(i + 1); - float A = glm::sin(angle); - float B = glm::fastSin(angle); - DiffMax = glm::max(DiffMax, glm::abs(B - A)); + const float begin = -glm::pi(); + const float end = glm::pi(); + float result = 0.f; + const std::clock_t timestamp1 = std::clock(); + for(float i=begin; i(time_fast)); + std::printf("cos Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; } +}//namespace fastCos - return Error; -} +namespace fastSin +{ + int perf() + { + const float begin = -glm::pi(); + const float end = glm::pi(); + float result = 0.f; + const std::clock_t timestamp1 = std::clock(); + for (float i = begin; i(time_fast)); + std::printf("sin Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; + } +}//namespace fastSin + +namespace fastTan +{ + int perf() + { + const float begin = -glm::pi(); + const float end = glm::pi(); + float result = 0.f; + const std::clock_t timestamp1 = std::clock(); + for (float i = begin; i(time_fast)); + std::printf("tan Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; + } +}//namespace fastTan + +namespace fastAcos +{ + int perf() + { + const float begin = -glm::pi(); + const float end = glm::pi(); + float result = 0.f; + const std::clock_t timestamp1 = std::clock(); + for (float i = begin; i(time_fast)); + std::printf("acos Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; + } +}//namespace fastAcos + +namespace fastAsin +{ + int perf() + { + const float begin = -glm::pi(); + const float end = glm::pi(); + float result = 0.f; + const std::clock_t timestamp1 = std::clock(); + for (float i = begin; i(time_fast)); + std::printf("asin Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; + } +}//namespace fastAsin + +namespace fastAtan +{ + int perf() + { + const float begin = -glm::pi(); + const float end = glm::pi(); + float result = 0.f; + const std::clock_t timestamp1 = std::clock(); + for (float i = begin; i(time_fast)); + std::printf("atan Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; + } +}//namespace fastAtan int main() { int Error(0); - Error += test_fastSin(); + Error += ::fastCos::perf(); + Error += ::fastSin::perf(); + Error += ::fastTan::perf(); + Error += ::fastAcos::perf(); + Error += ::fastAsin::perf(); + Error += ::fastAtan::perf(); return Error; }