I'm fairly new to programming and I've noticed a lot of discussions around optimized and unoptimized code. When I'm working on projects with AI tools like Cursor, my code seems to function well, but how can I assess if it's truly optimized for larger scale applications? Specifically, what techniques can I use to determine whether my code is optimized? Are there any example GitHub repositories demonstrating the differences between optimized and unoptimized versions? Additionally, for AI-generated code, are there any Markdown files or templates you use to guide the models while coding? What do these documents typically include? Finally, how can I identify when AI-generated code isn't optimized?
2 Answers
You shouldn't depend too heavily on AI tools like Cursor to handle everything for you. The issue is that if you don't fully understand the processes you're implementing, it can produce code that complicates things as your project grows. Investing time in learning coding principles is essential. You'll gain a better grasp of what works and what doesn't as you build your projects!
To figure out if your code is optimized, you can start by profiling it. There are definitely other factors affecting performance beyond just your code, so profiling provides a clearer picture. It’s important to benchmark your code under normal conditions first; this gives you a baseline to compare against. If your benchmarks are consistent, that indicates stability. Otherwise, you may need to delve deeper into timing for individual functions. But remember, logging can introduce delays, even when you're measuring performance!

I see your point! But for someone who's just starting out, are there basic techniques or tips for optimizing code that can be applied universally?