Compiling firmware with Linaro slightly improves performance

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
SkG
Posts: 18
Joined: Mon Mar 10, 2014 2:57 pm

Compiling firmware with Linaro slightly improves performance

Post by SkG » Tue May 13, 2014 5:11 pm

There was one thing in my mind that I wanted to do as soon as I get my pyboard and that was check if Linaro GCC increase the performance.

I used as abase the "benchmark" that is in the wiki: https://github.com/micropython/micropyt ... erformance

I put the following code in boot.py and then via serial console I ran benchmark():

Code: Select all

def performanceTest():
    millis = pyb.millis
    endTime = millis() + 10000
    count = 0
    while millis() < endTime:
        count += 1
    return count

def benchmark():
    c = 0
    for i in range(10):
        c += performanceTest()
    c = c/10
    print("Avg. Count: ", c)
With the "stock" firmware I got an avg of: 2117312
With the same version (git checkout v1.0) compiled with Linaro GCC 4.8 2014.01 I got an avg of: 2152395

That is 35083 iterations more. What do you think, It worth the difference? Anyone can suggest a proper benchmark?

SkG
Posts: 18
Joined: Mon Mar 10, 2014 2:57 pm

Re: Compiling firmware with Linaro slightly improves perform

Post by SkG » Wed May 14, 2014 8:04 pm

Seems that v1.0.1 runs a little bit faster, here the results with the same test:

GNU GCC 4.8: 2176580
Linaro GCC 4.8 2014.01: 2236090

davidb24v
Posts: 3
Joined: Mon Mar 03, 2014 4:32 pm

Re: Compiling firmware with Linaro slightly improves perform

Post by davidb24v » Fri May 23, 2014 9:04 pm

Thanks for this. It gave me an excuse to try out one of the "emitters".

With latest firmware (as of about 10 minutes ago) your benchmark gave me:
Avg. Count: 2.14166e+06
I then just added the "@micropython.native" decorator and re-pasted your performanceTest function and got:
Avg. Count: 4.06494e+06
Ok, so it's not a "real world" example, whatever. It's not even a factor of two.

However, if I can get "not even a factor of two" with a decorator then I'm impressed. Very impressed ;)

Post Reply