|Topic was automatically imported from the old Question2Answer platform.
What I am thinking of is :
I am currently trying to code efficient pathfinding system, and as I am changing mathematical operations, trying out various loops and approaches - all I can measure are framedrop and small freezes. I wish to know how much each line of code is contributing to this freeze, so I could optimize it better. Instead I have to rely on subjective duration of freeze.
I remove one needless boolean condition - freeze is slightly smaller. Or is it ? Was it in my head ? Should I try to search in arrays instead of in dictionaries ? Freeze seems to be shorter on arrays… or is it…? You know what I mean
Did anyone come up with a way to objectively test optimization of code ? Or better - of single lines of code ??
Hey everyone! I totally relate to the struggle of optimizing code and trying to measure its performance objectively. It can be incredibly frustrating when all we have to rely on our subjective observations like frame drops and freezes. I’ve been there, constantly questioning whether a small change actually made a difference or if it was just in my head.
One approach that has helped me is using profiling tools. These tools analyze the execution of your code and provide detailed information about the time spent in each function or line of code. By using a profiler, you can pinpoint exactly which parts of your code are causing the freezes and framedrops, and focus your optimization efforts there.
There are several great profiling tools available for different programming languages, such as cProfile for Python or Instruments for iOS development. These tools can give you valuable insights into the performance of your code and help you make informed decisions about optimization.
Another helpful technique is benchmarking. By creating specific test cases and measuring the execution time of different approaches or lines of code, you can compare their performance objectively. This way, you can identify the most time-consuming parts and prioritize your optimization efforts accordingly.
angelacow | 2023-06-12 13:58