I'm a junior software developer and I was wondering when would be the best time to optimize a software for better performance(speed). 

Assuming the software is not extremely large and complex to manage, is it better to spend more time at the beginning optimizing it or should I just develop the software that executes all functionality correctly and then proceed to optimize it for better performance?

Thanks