From 183c7141e2674b07441655a1f590688d8b1886a4 Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 14:44:51 +0100 Subject: [PATCH 1/7] performance test for glm::fastCos --- test/gtx/gtx_fast_trigonometry.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index c7ad3e6e..d3787708 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -9,10 +9,36 @@ #include #include +#include +#include + +namespace fastCos{ + 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_fastCos)); + std::printf("cos Time %d clocks\n", static_cast(time_cos)); + return time_fastCos < time_cos ? 0 : 1; + } +} + int main() { int Error(0); + Error += ::fastCos::perf(); + return Error; } From 74cfc7451aefde437a663cf0f61e456fbaf53e9a Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 15:02:17 +0100 Subject: [PATCH 2/7] test perf fastSin --- test/gtx/gtx_fast_trigonometry.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index d3787708..a4f7f8e6 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -33,12 +33,33 @@ namespace fastCos{ } } +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; + } +} int main() { int Error(0); Error += ::fastCos::perf(); + Error += ::fastSin::perf(); return Error; } From c4b5fa2a931aae05b3cea2c26a3e51f767ae73fb Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 15:02:26 +0100 Subject: [PATCH 3/7] test perf fastTan --- test/gtx/gtx_fast_trigonometry.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index a4f7f8e6..ff65878b 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -54,12 +54,35 @@ 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; + } +} + + int main() { int Error(0); Error += ::fastCos::perf(); Error += ::fastSin::perf(); + Error += ::fastTan::perf(); return Error; } From 43387c81de38e3cdcafa703b53191b9d1a8b77d5 Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 15:05:33 +0100 Subject: [PATCH 4/7] test perf fastAcos --- test/gtx/gtx_fast_trigonometry.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index ff65878b..0856dfc2 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -75,6 +75,27 @@ 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; + } +} + int main() { @@ -83,6 +104,7 @@ int main() Error += ::fastCos::perf(); Error += ::fastSin::perf(); Error += ::fastTan::perf(); + Error += ::fastAcos::perf(); return Error; } From a7b3fca0b2caa11cee796ab75e77e4e095bffc0d Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 15:06:07 +0100 Subject: [PATCH 5/7] test perf fastAsin --- test/gtx/gtx_fast_trigonometry.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index 0856dfc2..7b27cbf4 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -96,6 +96,27 @@ 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; + } +} + int main() { @@ -105,6 +126,7 @@ int main() Error += ::fastSin::perf(); Error += ::fastTan::perf(); Error += ::fastAcos::perf(); + Error += ::fastAsin::perf(); return Error; } From ef1c33d2d5ed09bb3609a9abf20c0b7d1f375acc Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 15:20:53 +0100 Subject: [PATCH 6/7] test perf fastAtan --- test/gtx/gtx_fast_trigonometry.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index 7b27cbf4..051c5d2d 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -117,6 +117,27 @@ 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; + } +} + int main() { @@ -127,6 +148,7 @@ int main() Error += ::fastTan::perf(); Error += ::fastAcos::perf(); Error += ::fastAsin::perf(); + Error += ::fastAtan::perf(); return Error; } From b3bdf83bd823ec2bbc352fd0922a02cfa3db333b Mon Sep 17 00:00:00 2001 From: Mathias Labeyrie Date: Wed, 5 Nov 2014 15:24:47 +0100 Subject: [PATCH 7/7] rename some vars --- test/gtx/gtx_fast_trigonometry.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/gtx/gtx_fast_trigonometry.cpp b/test/gtx/gtx_fast_trigonometry.cpp index 051c5d2d..7eaffe77 100644 --- a/test/gtx/gtx_fast_trigonometry.cpp +++ b/test/gtx/gtx_fast_trigonometry.cpp @@ -25,11 +25,11 @@ namespace fastCos{ for(float i=begin; i(time_fastCos)); - std::printf("cos Time %d clocks\n", static_cast(time_cos)); - return time_fastCos < time_cos ? 0 : 1; + const std::clock_t time_fast = timestamp2 - timestamp1; + const std::clock_t time_default = timestamp3 - timestamp2; + std::printf("fastCos Time %d clocks\n", static_cast(time_fast)); + std::printf("cos Time %d clocks\n", static_cast(time_default)); + return time_fast < time_default ? 0 : 1; } }