What makes efficient code?

06 Jun 2013

Hi all,

I recently tried to log data from a UM6 orientation sensor to a local file on mbed NXP LPC1768 via UART and ran into problems with it because it didn't like how fast I was trying to do it (every 10ms). My supervisor mentioned that multiple printf functions can really slow a program down, so I consolidated all of them into one. I also ended up log data to an SD card instead, which solve my problem.

This has got me wondering about what code in general is slow? Does anyone have any tips and tricks for speeding up code?

Nathan

06 Jun 2013

Can you run your UART faster? The USB UART can run at 921600 baud

...kevin

07 Jun 2013

I would expect the localfilesystem was the problem, that might not be great for saving small amounts of data really often. With the printfs, do you mean to the UART or to the localfilesystem? Because printf to UART really doesn't matter in how many you split it, it just needs to send that data.