"Optimize: ...." what does it do?

Post here first, or if you can't find a relevant section!
Post Reply
not_defined
Posts: 1
Joined: Sat Jan 07, 2023 9:04 pm

"Optimize: ...." what does it do?

Post by not_defined »

Hello. What do Smallest, "Fast (-O1)", "Faster (-O2)", "Fastest (-O3)" do in "Tools > Optimize:" in Arduino IDE? Which one to choose for which situations?
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: "Optimize: ...." what does it do?

Post by ag123 »

use -Os smallest unless your chip has lots of sram and flash, -O{2,3} etc is intended to be optimized for speed, more often at the expense of flash and sram. Not all chips can benefit from it, e.g. stm32f4xx and higher series (e.g. f7, h7) are more likely to benefit from those optimizations as the chips has more hardware to benefit from those optimizations
firstwaterpolo
Posts: 1
Joined: Wed Mar 01, 2023 8:18 am

Re: "Optimize: ...." what does it do?

Post by firstwaterpolo »

frequent at the price of sram and flash memory. Nevertheless, the stm32f4xx and later series (such as the f7 and h7) are more likely to reap the rewards of these enhancements since they have more hardware capable of handling them.
Boaslo
Posts: 1
Joined: Tue Mar 14, 2023 1:09 am

Re: "Optimize: ...." what does it do?

Post by Boaslo »

To my knowledge -Os is the smallest unless your chip has a lot of sram and flash, -O{2,3} is used to maximize for speed, often at the expense of flash and sram.
Post Reply

Return to “General discussion”