Skip to content

Current compiler much better ?!? #2

Description

@FredM67

Hi,
Could it be, the compiler is in-between much better ?
With this code

void loop()
{
  Serial.println("*** loop start ***");

  int16_t number1 = random(100);

  int32_t sum{0};

  auto time_start = micros();
  for (int16_t idx = 0; idx < 25000; ++idx)
  {
    int32_t mul = number1 * idx;
    sum += mul;
  }
  auto time_stop = micros();
  Serial.println(time_stop - time_start);

  Serial.println("*** asm ***");

  int32_t sum_asm{0};

  auto time_start_asm = micros();
  for (int16_t idx_asm = 0; idx_asm < 25000; ++idx_asm)
  {
    int32_t mul_asm;
    MultiS16X16to32(mul_asm, number1, idx_asm);
    sum_asm += mul_asm;
  }
  auto time_stop_asm = micros();

  Serial.println(time_stop_asm - time_start_asm);

  delay(5000);
}

I get

*** loop start ***
4
*** asm ***
42712

in the serial monitor !!
BTW, whenever I increase each loop, the first loop doesn't take longer ?!? Did I miss something?
I've tried with a constant... same effect !

Fred

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions