void setup() {
  // put your setup code here, to run once:
  pinMode(A0, INPUT);
  pinMode(2, OUTPUT);
  pinMode(13, OUTPUT);

  Serial.begin(115200);
  Serial.println("Hello !");
}

unsigned long lastLoop_ms = 0;
unsigned long period_ms = 3;

const uint64_t m = 4294967296; // Modulus (large prime number)
const uint64_t a = 1664525;    // Multiplier
const uint64_t c = 1013904223; // Increment
uint64_t seed = 12345; // You can change this to any non-zero value

// Generate a pseudo-random number
uint32_t generateRandom() {
    seed = (a * seed + c) % m;
    return (uint32_t)(seed & 0xffffffff);
}



static inline void start() {
    // IO13 = PortB:Pin5
    noInterrupts();
    PORTB |= (1 << 5);
}

static inline void stop() {
    PORTB &= ~(1 << 5);
    interrupts();
}

void loop() {
  // Periodic trigger
  if (millis() - lastLoop_ms > period_ms) {
    lastLoop_ms += period_ms;

    //Serial.println(millis());

    // Measure some execution time on oscilloscope
    start(); // 127ns
    // volatile uint32_t x = micros(); // 2937 - 2938ns
    // volatile uint32_t y = millis(); // 1312 - 1313ns
    // volatile float f = millis();    // 3312 - 5751ns, depends on value
    // volatile float f = millis() * .001f; // 11 - 15µs, 
    // Serial.println(millis());       // @115200baud: 199 - 202µs; @38400 baud: 65 - 247µs
    //volatile float f = sin(millis());  // 109 - 140µs; 126 +/- 4 µs
    volatile float f = sqrt(millis());   // 30 - 36µs
    //volatile float f = sqrt(12.0f);   // 
    
    stop();
  }

}
timing-measurementBreakout
ScopeBreakout