Calculation benchmark of micropython in different hardware

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

I thought so...

Post by pythoncoder » Sat Aug 25, 2018 5:03 pm

:D :D
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Calculation benchmark of micropython in different hardware

Post by OutoftheBOTS_ » Sat Aug 25, 2018 9:12 pm

I watched this last video by Damian George https://www.youtube.com/watch?v=hHec4qL00x0 night and was blown away by how much doing the same thing but in a slightly different way can change the speed by a factor of easily up to 1000

It seems heap access is super slow. when you run a line of code in the main loop it runs as a global varible on the heap but if you out it in a function then it runs as a local variable on the stack. I think ESP32 with psRAM this will be mutiplied because heao will use psRAM which is even slower again.

Following Damian video you could rerun the test doing the same thing but using slightly different code you might find very different results.

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: Calculation benchmark of micropython in different hardware

Post by shaoziyang » Sun Aug 26, 2018 8:17 am

I have modify test script, and made more test. I have put it in github:

https://github.com/shaoziyang/micropython_benchmarks

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: Calculation benchmark of micropython in different hardware

Post by loboris » Sun Aug 26, 2018 9:28 am

Notes on ESP32:
If psRAM is used, the results may vary because both Flash and psRAM are cached in internal RAM in 32K blocks.
The result may be different depending on if all the used variables are in the in the same 32K block or the new block must be cached from psRAM. It may also vary depending on the position of the used functions in Flash.

On ESP32-LoBo double (64-bit) is used for MicroPython floats, on official MicroPython float (32-bit) is used.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Calculation benchmark of micropython in different hardware

Post by pythoncoder » Mon Aug 27, 2018 6:33 am

OutoftheBOTS_ wrote:
Sat Aug 25, 2018 9:12 pm
...It seems heap access is super slow...
The principal problem is that heap allocations are not deterministic: while normally fast they can occasionally trigger a garbage collection which may take 5ms. In some applications this can be circumvented by periodically issuing gc.collect(). This reduces GC time to <1ms. More importantly you can sometimes do GC at a time when it has no effect on application performance. Further, periodic GC can reduce heap fragmentation which can cause applications to fail.

The above times are times I have measured in applications on a Pyboard. Mileages will vary ;)
Peter Hinch
Index to my micropython libraries.

Post Reply