Fixed excessive GTX_fast_trigonometry execution time #396

This commit is contained in:
Christophe Riccio 2015-09-06 21:36:05 +02:00
parent d7b01eb9ad
commit 992a56089b
2 changed files with 27 additions and 27 deletions

View File

@ -60,6 +60,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
- Fixed link errors on compilers not supported default function #377
- Fixed compilation warnings in vec4
- Fixed non-identity quaternions for equal vectors #234
- Fixed excessive GTX_fast_trigonometry execution time #396
#### [GLM 0.9.7.0](https://github.com/g-truc/glm/releases/tag/0.9.7.0) - 2015-08-02
##### Features:

View File

@ -44,18 +44,18 @@
namespace fastCos
{
int perf()
int perf(bool NextFloat)
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::fastCos(i);
const std::clock_t timestamp2 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::cos(i);
const std::clock_t timestamp3 = std::clock();
@ -78,18 +78,18 @@ namespace fastSin
}
*/
int perf()
int perf(bool NextFloat)
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::fastSin(i);
const std::clock_t timestamp2 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::sin(i);
const std::clock_t timestamp3 = std::clock();
@ -104,18 +104,18 @@ namespace fastSin
namespace fastTan
{
int perf()
int perf(bool NextFloat)
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::fastTan(i);
const std::clock_t timestamp2 = std::clock();
for (float i = begin; i < end; i = glm::next_float(i))
for (float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::tan(i);
const std::clock_t timestamp3 = std::clock();
@ -130,18 +130,18 @@ namespace fastTan
namespace fastAcos
{
int perf()
int perf(bool NextFloat)
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::fastAcos(i);
const std::clock_t timestamp2 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::acos(i);
const std::clock_t timestamp3 = std::clock();
@ -157,16 +157,16 @@ namespace fastAcos
namespace fastAsin
{
int perf()
int perf(bool NextFloat)
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::fastAsin(i);
const std::clock_t timestamp2 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::asin(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
@ -180,16 +180,16 @@ namespace fastAsin
namespace fastAtan
{
int perf()
int perf(bool NextFloat)
{
const float begin = -glm::pi<float>();
const float end = glm::pi<float>();
float result = 0.f;
const std::clock_t timestamp1 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::fastAtan(i);
const std::clock_t timestamp2 = std::clock();
for(float i = begin; i < end; i = glm::next_float(i))
for(float i = begin; i < end; i = NextFloat ? glm::next_float(i) : i += 0.1f)
result = glm::atan(i);
const std::clock_t timestamp3 = std::clock();
const std::clock_t time_fast = timestamp2 - timestamp1;
@ -414,13 +414,12 @@ namespace taylorCos
return Error;
}
int perf()
int perf(std::size_t const Samples)
{
int Error = 0;
float const Begin = -glm::pi<float>();
float const End = glm::pi<float>();
std::size_t const Samples = 10000000;
Error += perf_cos(Begin, End, Samples);
Error += perf_fastCosOld(Begin, End, Samples);
@ -462,15 +461,15 @@ int main()
int Error(0);
Error += ::taylorCos::test();
Error += ::taylorCos::perf();
Error += ::taylorCos::perf(1000);
# ifdef NDEBUG
Error += ::fastCos::perf();
Error += ::fastSin::perf();
Error += ::fastTan::perf();
Error += ::fastAcos::perf();
Error += ::fastAsin::perf();
Error += ::fastAtan::perf();
Error += ::fastCos::perf(false);
Error += ::fastSin::perf(false);
Error += ::fastTan::perf(false);
Error += ::fastAcos::perf(false);
Error += ::fastAsin::perf(false);
Error += ::fastAtan::perf(false);
# endif//NDEBUG
return Error;