Code optimization



  • I'm reading forums and I'm writing, "Try to do the optimised code." Tell me what this is and how to do the optimised code?



  • I'm reading forums and I'm writing, "Try to do the optimised code." Tell me what this is and how to do the optimised code?

    If you asked this question without the code, you don't need the optimization yet. Write a ready working code and preferably an understandable code. When you write the program, you'll see if it works fast enough. If there is a lack of productivity, then we have to think about optimization.

    To be optimised, the weakest places should be explored and optimized. Fragile seats are usually cycles (more irration and investment, the greater the likelihood that this is a weak place), some systemic challenges, and algorithms that are highly complex. Looking for these weak spots with the help of profilers.

    People are optimizing the code all day, and only 10 per cent of the velocity wins are those who quickly optimized a weak spot and accelerated 10 times. It's because the first ones didn't understand this rule and optimize everything.

    Cycles are customarily optimized to produce out-of-cycle calculations. It's often handled by the compilator. If the weakness is some known algorithm (seeing, sorting, etc.), we need to choose a less complex algorithm. But he can consume more memory. So, by optimizing productivity, you can get a code that requires more memory (although there's plenty of PC on it). There is a balance between productivity, memory consumption, code readability and development time.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2