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