mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-25 17:15:42 +02:00
Tests/AK: Add perf tests for tan(0, asin(), acos(), atan()
On my system, with macOS system libm (including the existing
sin(), cos() perf tests):
% Build/lagom/bin/TestAKMath
...
Running benchmark 'bench_trig_cos'.
Completed benchmark 'bench_trig_cos' in 66ms
Running benchmark 'bench_trig_cosf'.
Completed benchmark 'bench_trig_cosf' in 58ms
Running benchmark 'bench_trig_sin'.
Completed benchmark 'bench_trig_sin' in 54ms
Running benchmark 'bench_trig_sinf'.
Completed benchmark 'bench_trig_sinf' in 58ms
Running benchmark 'bench_trig_tan'.
Completed benchmark 'bench_trig_tan' in 75ms
Running benchmark 'bench_trig_tanf'.
Completed benchmark 'bench_trig_tanf' in 82ms
Running benchmark 'bench_trig_acos'.
Completed benchmark 'bench_trig_acos' in 11ms
Running benchmark 'bench_trig_acosf'.
Completed benchmark 'bench_trig_acosf' in 10ms
Running benchmark 'bench_trig_asin'.
Completed benchmark 'bench_trig_asin' in 11ms
Running benchmark 'bench_trig_asinf'.
Completed benchmark 'bench_trig_asinf' in 11ms
Running benchmark 'bench_trig_atan'.
Completed benchmark 'bench_trig_atan' in 60ms
Running benchmark 'bench_trig_atanf'.
Completed benchmark 'bench_trig_atanf' in 63ms
With serenity libm (#26662):
% Build/lagom/bin/TestAKMath
...
Completed benchmark 'bench_trig_cos' in 87ms
Running benchmark 'bench_trig_cosf'.
Completed benchmark 'bench_trig_cosf' in 65ms
Running benchmark 'bench_trig_sin'.
Completed benchmark 'bench_trig_sin' in 75ms
Running benchmark 'bench_trig_sinf'.
Completed benchmark 'bench_trig_sinf' in 67ms
Running benchmark 'bench_trig_tan'.
Completed benchmark 'bench_trig_tan' in 184ms
Running benchmark 'bench_trig_tanf'.
Completed benchmark 'bench_trig_tanf' in 163ms
Running benchmark 'bench_trig_acos'.
Completed benchmark 'bench_trig_acos' in 10ms
Running benchmark 'bench_trig_acosf'.
Completed benchmark 'bench_trig_acosf' in 10ms
Running benchmark 'bench_trig_asin'.
Completed benchmark 'bench_trig_asin' in 10ms
Running benchmark 'bench_trig_asinf'.
Completed benchmark 'bench_trig_asinf' in 10ms
Running benchmark 'bench_trig_atan'.
Completed benchmark 'bench_trig_atan' in 176ms
Running benchmark 'bench_trig_atanf'.
Completed benchmark 'bench_trig_atanf' in 184ms
This commit is contained in:
@@ -46,30 +46,70 @@ TEST_CASE(wrap_to_range)
|
||||
EXPECT_EQ(AK::wrap_to_range(-85., 180.), -85.);
|
||||
}
|
||||
|
||||
#define BENCHMARK_TRIG(type, function) \
|
||||
do { \
|
||||
for (type value = -4 * AK::Pi<type>; value < 4 * AK::Pi<type>; value += static_cast<type>(0.000001)) { \
|
||||
auto result = function(value); \
|
||||
AK::taint_for_optimizer(result); \
|
||||
} \
|
||||
#define BENCHMARK_TRIG(type, function, from, to) \
|
||||
do { \
|
||||
for (type value = from; value < to; value += static_cast<type>(0.000001)) { \
|
||||
auto result = function(value); \
|
||||
AK::taint_for_optimizer(result); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
BENCHMARK_CASE(bench_trig_cos)
|
||||
{
|
||||
BENCHMARK_TRIG(double, AK::cos);
|
||||
BENCHMARK_TRIG(double, AK::cos, -4 * AK::Pi<double>, 4 * AK::Pi<double>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_cosf)
|
||||
{
|
||||
BENCHMARK_TRIG(float, AK::cos);
|
||||
BENCHMARK_TRIG(float, AK::cos, -4 * AK::Pi<float>, 4 * AK::Pi<float>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_sin)
|
||||
{
|
||||
BENCHMARK_TRIG(double, AK::sin);
|
||||
BENCHMARK_TRIG(double, AK::sin, -4 * AK::Pi<double>, 4 * AK::Pi<double>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_sinf)
|
||||
{
|
||||
BENCHMARK_TRIG(float, AK::sin);
|
||||
BENCHMARK_TRIG(float, AK::sin, -4 * AK::Pi<float>, 4 * AK::Pi<float>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_tan)
|
||||
{
|
||||
BENCHMARK_TRIG(double, AK::tan, -4 * AK::Pi<double>, 4 * AK::Pi<double>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_tanf)
|
||||
{
|
||||
BENCHMARK_TRIG(float, AK::tan, -4 * AK::Pi<float>, 4 * AK::Pi<float>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_acos)
|
||||
{
|
||||
BENCHMARK_TRIG(double, AK::acos, -1.0, 1.0);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_acosf)
|
||||
{
|
||||
BENCHMARK_TRIG(float, AK::acos, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_asin)
|
||||
{
|
||||
BENCHMARK_TRIG(double, AK::asin, -1.0, 1.0);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_asinf)
|
||||
{
|
||||
BENCHMARK_TRIG(float, AK::asin, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_atan)
|
||||
{
|
||||
BENCHMARK_TRIG(double, AK::atan, -4 * AK::Pi<double>, 4 * AK::Pi<double>);
|
||||
}
|
||||
|
||||
BENCHMARK_CASE(bench_trig_atanf)
|
||||
{
|
||||
BENCHMARK_TRIG(float, AK::atan, -4 * AK::Pi<float>, 4 * AK::Pi<float>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user