I was testing out the cross compiler to see how much faster my code could run if the microcontroller didn't have to compile it anymore.
After reading the following posts I realised that I couldn't just cross compile main.py to main.mpy:
viewtopic.php?f=6&t=8410&p=47777&hilit=main.mpy#p47777
viewtopic.php?f=2&t=7627&p=43920&hilit= ... ler#p43920
So I did what the posts suggested and compiled my code with a different name and imported that .mpy module in the main.py
To test this I wrote a program that wakes the microcontroller up and puts it back to sleep (with a timer for 1s) and just keeps on doing this.
I used an ESP32_DevKitC_V4 with the WROOM-32 module.
My original code (main.py) is the following:
Code: Select all
import machine
machine.deepsleep(1000)
I loaded this file to the flash memory. (So no frozen module)
And then my new code (main.py) became the following:
Code: Select all
import my_code
When I zoom in on one active region I get the following graph (green = original code and red = new code with cross compiler):
So as you can see there isn't much difference between the two. (green = 685 ms and red = 700 ms)
But what surprised me is that the cross compiled code actually takes longer to execute! (15 ms)
Am I doing something wrong or is this always the case with the cross compiler and is it only meant for using less RAM?
And also I second question: can you see on the graph were the compilation takes place and how long it takes?
Thanks in advance!