Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8374

MicroPython • Re: Benchmark Pico 2

$
0
0
Try to change this function from earthworm mode

Code:

def Fibonacci(n):  if n <= 1 : return n  else      : return Fibonacci(n-1) + Fibonacci(n-2)
To a native snake

Code:

@micropython.nativedef Fibonacci(n):  if n <= 1 : return n  else      : return Fibonacci(n-1) + Fibonacci(n-2)
And give it some venom to be like a viper

Code:

@micropython.viperdef Fibonacci( n: int) -> int:  if n <= 1 : return int(n)  else      : return int( Fibonacci(n-1) + Fibonacci(n-2) )
And see the results changing drastically.
BTW your RISC-V version looks to be better compiled than the stock one
Maybe the differences are form some not so well optimized interpreter code.

RISC-V

Code:

.----------.------------.-------.------------.-------------.| Hardware | Python     |  MHz  |   Seconds  |  Multiplier ||----------|------------|-------|------------|-------------||  RP2350  | 1.24.0 on  |  250  |  0.238593  |   15   7.7  ||RISCVviper| 2024-10-25 |  125  |  0.477184  |    8   7.7  |`----------^------------^-------^------------^-------------'.----------.------------.-------.------------.-------------.| Hardware | Python     |  MHz  |   Seconds  |  Multiplier ||----------|------------|-------|------------|-------------||  RP2350  | 1.24.0 on  |  250  |  0.468229  |    8   3.9  ||RISCVnativ| 2024-10-25 |  125  |  0.936364  |    4   3.9  |`----------^------------^-------^------------^-------------'.----------.------------.-------.------------.-------------.| Hardware | Python     |  MHz  |   Seconds  |  Multiplier ||----------|------------|-------|------------|-------------||  RP2350  | 1.24.0 on  |  250  |  1.346400  |    3   1.4  ||  RISCV   | 2024-10-25 |  125  |  2.692783  |    1   1.4  |`----------^------------^-------^------------^-------------'
ARM

Code:

.----------.------------.-------.------------.-------------.| Hardware | Python     |  MHz  |   Seconds  |  Multiplier ||----------|------------|-------|------------|-------------||  RP2350  | 1.24.0 on  |  250  |  0.271833  |   14   6.8  ||ARM viper | 2024-10-25 |  125  |  0.543536  |    7   6.8  |`----------^------------^-------^------------^-------------'.----------.------------.-------.------------.-------------.| Hardware | Python     |  MHz  |   Seconds  |  Multiplier ||----------|------------|-------|------------|-------------||  RP2350  | 1.24.0 on  |  250  |  0.531003  |    7   3.5  ||ARM native| 2024-10-25 |  125  |  1.061867  |    3   3.5  |`----------^------------^-------^------------^-------------'.----------.------------.-------.------------.-------------.| Hardware | Python     |  MHz  |   Seconds  |  Multiplier ||----------|------------|-------|------------|-------------||  RP2350  | 1.24.0 on (|  250  |  0.561808  |    7   3.3  ||   ARM    | 2024-10-25 |  125  |  1.123654  |    3   3.3  |`----------^------------^-------^------------^-------------'

Statistics: Posted by gmx — Mon Nov 11, 2024 4:49 am



Viewing all articles
Browse latest Browse all 8374

Trending Articles