▲ | Benchmarking MicroPython(blog.miguelgrinberg.com) | ||||||||||||||||||||||
21 points by ibobev 2 days ago | 14 comments | |||||||||||||||||||||||
▲ | jononor 2 days ago | parent | next [-] | ||||||||||||||||||||||
This should not be used to conclude on the viability of using MicroPython for numeric type tasks. For that one should at least take into account the following: Integers are much faster than floats (floats involve a pointer and a heap allocation, integers are stored in a single word/object). array.array is preferred over list for something like sort. Continuous memory representation of numbers versus general purpose list of objects. MicroPython has on-board "JIT" (native/viper emitters), have to explicitly annotate the function. Should give 4-10x improvements for this case. MicroPython has an on-board assembler, so one can write ARM assembly and get that to a function. MicroPython also has support for C modules, which expose a Python API. Including dynamic native modules which can be installed at runtime with the package manager. Bubblesort is O(n*2), which hurts for even a few thousand numbers. Actual sorting on a microcontroller should be done with an O(n log n) algorithm. | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | mbirth 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
I'm missing testing the different emitters as demonstrated here: https://www.kickstarter.com/projects/214379695/micro-python-... Not sure whether they're supported on all the architectures, though. | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | Archit3ch a day ago | parent | prev | next [-] | ||||||||||||||||||||||
You can drop down to C and call it from MicroPython if you want to count cycles. Of course, you have to recompile your C every time it changes, which is annoying when you're used to the REPL workflow. | |||||||||||||||||||||||
▲ | drewcoo 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
Somehow, I don't mind that the code blew the stack because it was recursion without memoization. Blowing the stack should be a pretty clear sign to figure out why and fix it. | |||||||||||||||||||||||
▲ | mrheosuper 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
Generate 2000 random numbers and sorting them using bubble sort on 160Mhz 32bit mcu takes 80 seconds ? This is exactly why micropython is a toy. | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | wewewedxfgdf 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
As the author points out, performance is pretty much irrelevant - it is a rewrite of python prioritizing memory usage. | |||||||||||||||||||||||
▲ | zem 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
would have been nice to see benchmarks against the equivalent c code running on the same microprocessor, not against micropython code running on different hardware. the post just told me that microprocessors are slow, not how well micropython performs. | |||||||||||||||||||||||
▲ | 2 days ago | parent | prev | next [-] | ||||||||||||||||||||||
[deleted] | |||||||||||||||||||||||
▲ | snvzz 2 days ago | parent | prev [-] | ||||||||||||||||||||||
>pico 2w ARM or RISC-V? |