Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log/exp #6

Open
FrankBoesing opened this issue Jul 14, 2021 · 2 comments
Open

log/exp #6

FrankBoesing opened this issue Jul 14, 2021 · 2 comments

Comments

@FrankBoesing
Copy link

FrankBoesing commented Jul 14, 2021

Just a qestion, have you tested that your log and exp implementations are really faster than the fpu?

@MarkzP
Copy link
Owner

MarkzP commented Jul 15, 2021

Here's a quick test on the T3.2, 96Mhz, Faster:

void setup()
{
  unsigned long start;
  float f;
  float q;

  randomSeed(12345);
  Serial.println("Go!");
  start = micros();

  for (int i = 0; i < 1000000; ++i)
  {
    f = random(10000) / 10000;

    q = log2f(f);
       
    (void)q;
  }

  unsigned long t = micros() - start;
  Serial.print("Done: "); Serial.print(t); Serial.println();
}

Here are the results:

    q = log(f);                 // 7557535
    q = log2f(f);               // 7808295
    q = log2f_approx(f);        // 5178506

    q = exp(f);                 // 9019425
    q = expf(f);                // 6514553
    q = expf_approx(f);         // 5555512

I would say it's a modest improvement at best on the T3.2, but still worth it IMHO

@MarkzP
Copy link
Owner

MarkzP commented Jul 15, 2021

Now I need to repeat this on a T3.5 (just need to find one!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants