|
Forum Index : Microcontroller and PC projects : Micropython is faster than MMBasic :-(
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11662 |
One of my favourite benchmarks is the calculation of the solar eclipse. solar_eclipse.zip The data I use to test with is: 12,1,2000 39,40,36 -104,57,12 1644 30 Running on a HDMI build at 378 MHz this takes 13.23 seconds Converting this to Micropython 1:1 solar_eclipse_py.zip This runs in 8.77 seconds at 378MHz! but Micropython has a trick up its sleeve using the ulab library solar_eclipse_ulab.zip And now it runs in 7.44 seconds For reference if I run the Basic code on a 480MHz STM32H743 which has H/W double precision floating point it takes 7 seconds |
||||
| thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 4379 |
Damn snakes, spoiling it for everyone, can't help but think that happened somewhere else .Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 688 |
I notice the BASIC version has a BASIC subroutine for matrix transpose. MMBasic has one built in. Would using the MATH subroutine be faster than the one written in BASIC? |
||||
| PhenixRising Guru Joined: 07/11/2023 Location: United KingdomPosts: 2012 |
BASIC code is the prettiest though |
||||
| scruss Senior Member Joined: 20/09/2021 Location: CanadaPosts: 110 |
MicroPython has a perfectly good math.atan2(), which will be faster than a hand-rolled equivalent. MicroPython's complete lack of a useful sgn() function, however, is a pain. I wonder how much faster it would be compiled with single-precision floating point. That's the norm for MicroPython |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 11662 |
It would be a lot faster, but, for example, that solar eclipse program simply fails. Any complex math needs double precision |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |