Profile and Improve Performance
Write your code to be simple and readable, especially for the first implementation. Code that is prematurely optimized can be unnecessarily complex without providing a significant gain in performance. Then, if speed is an issue, you can measure how long your code takes to run and profile your code to identify bottlenecks. If necessary, you can take steps to improve performance.
Apps
| Profiler | Run code and measure execution time to improve performance |
Functions
Topics
- Measure the Performance of Your Code
Use the
timeitfunction or the stopwatch timer functions,ticandtoc, to time how long your code takes to run. - Profile Your Code to Improve Performance
Use the Profiler to measure the time it takes to run your code and identify which lines of code consume the most time or which lines do not run.
- Measure Code Complexity Using Cyclomatic Complexity
Quantify code complexity based on cyclomatic complexity.
- Techniques to Improve Performance
To speed up the performance of your code, there are several techniques that you can consider.