Use log2 now that NDK requires at least API 21 which includes it. (#1822)

Fixes #1820
This commit is contained in:
dominic 2024-07-24 14:25:32 +01:00 committed by GitHub
parent fa236ed6e6
commit 378fe693a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 8 deletions

View File

@ -27,7 +27,6 @@ namespace benchmark {
// Internal function to calculate the different scalability forms // Internal function to calculate the different scalability forms
BigOFunc* FittingCurve(BigO complexity) { BigOFunc* FittingCurve(BigO complexity) {
static const double kLog2E = 1.44269504088896340736;
switch (complexity) { switch (complexity) {
case oN: case oN:
return [](IterationCount n) -> double { return static_cast<double>(n); }; return [](IterationCount n) -> double { return static_cast<double>(n); };
@ -36,15 +35,12 @@ BigOFunc* FittingCurve(BigO complexity) {
case oNCubed: case oNCubed:
return [](IterationCount n) -> double { return std::pow(n, 3); }; return [](IterationCount n) -> double { return std::pow(n, 3); };
case oLogN: case oLogN:
/* Note: can't use log2 because Android's GNU STL lacks it */ return [](IterationCount n) -> double {
return [](IterationCount n) { return std::log2(static_cast<double>(n));
return kLog2E * std::log(static_cast<double>(n));
}; };
case oNLogN: case oNLogN:
/* Note: can't use log2 because Android's GNU STL lacks it */ return [](IterationCount n) -> double {
return [](IterationCount n) { return static_cast<double>(n) * std::log2(static_cast<double>(n));
return kLog2E * static_cast<double>(n) *
std::log(static_cast<double>(n));
}; };
case o1: case o1:
default: default: