Skip to content

Commit

Permalink
Use log2 now that NDK requires at least API 21 which includes it.
Browse files Browse the repository at this point in the history
Fixes #1820
  • Loading branch information
dmah42 committed Jul 24, 2024
1 parent df44bf7 commit ab53423
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/complexity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace benchmark {

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

0 comments on commit ab53423

Please sign in to comment.