Closed
Description
Hi,
I did a simple loop test in python to compare with my STM32F4 based MicroPython board and the results are quite unexpected. CircuitPython 4.x is 16x slower than MicroPython for an equivalent CPU frequency.
Details available here:
https://forums.adafruit.com/viewtopic.php?f=60&t=152372&p=753830#p753830
Test code:
def test():
s = time.monotonic
count = 0
r = range(0, 10000000)
startTime = s()
for count in r:
pass
endTime = s()
duration = endTime - startTime
return duration
Results:
- 18 766ms on Meowbit/MP at 56 MHz (using pyb.millis)
- 12 506ms on my Meowbit/MP at 84 MHz (using pyb.millis)
- 138 390ms on my Pygamer/CP at 120 MHz (using time.monotonic)
- 86 000ms on my Pygamer/CP at 200 MHz (using time.monotonic)
C module reference:
#define NOP asm volatile(" nop \n\t")
uint64_t start = ticks_ms;
uint32_t count = 0;
uint64_t end = 0;
for(count=0; count<10000000; count++) { NOP; }
end = ticks_ms;
uint32_t delta = end - start;
printf("Delta: %lu\n", delta);
Results:
- 715ms at 56MHz on Meowbit/MP
- 477ms at 84MHz on Meowbit/MP
- 334ms at 120MHz on pygamer/CP
- 200ms at 200MHz on pygamer/CP
Real issue or I did something wrong ?