- Mastering Delphi Programming:A Complete Reference Guide
- Primo? Gabrijel?i?
- 253字
- 2021-06-24 12:33:29
Don't guess, measure!
There is only one way to get a good picture about the fast and slow parts of a program—by measuring it. We can do it manually, by inserting time-measuring calls in the code, or we can use specialized tools. We have a name for measuring—profiling—and we call specialized tools for measuring profilers.
In the rest of this chapter, we'll look at different techniques of measuring the execution speed. First we will measure the now familiar program, SlowCode, with a simple software stopwatch and then we'll look at a few open source and commercial profilers.
Before we start, I'd like to point out a few basic rules that apply to all profiling techniques:
- Always profile without the debugger. The debugger will slow the execution in unexpected places and that will skew the results. If you are starting your program from the Delphi IDE, just press Ctrl+Shift+F9 instead of F9.
- Try not to do anything else on the computer while profiling. Other programs will take the CPU away from the measured program which will make it run slower.
- Take care that the program doesn't wait for user action (data entry, button click) while profiling. This will completely skew the report.
- Repeat the tests a few times. Execution times will differ because Windows (and any other OS that Delphi supports) will always execute other tasks besides running your program.
- All the above especially holds for multithreaded programs, which is an area explored in Chapters 5 to 7.
推薦閱讀
- 深入理解Spring Cloud與實戰
- Mastering Manga Studio 5
- OUYA Game Development by Example
- Practical Machine Learning with R
- 固態存儲:原理、架構與數據安全
- Building 3D Models with modo 701
- 基于Proteus仿真的51單片機應用
- 微型計算機系統原理及應用:國產龍芯處理器的軟件和硬件集成(基礎篇)
- Istio服務網格技術解析與實踐
- WebGL Hotshot
- 微控制器的應用
- Mastering Quantum Computing with IBM QX
- 筆記本電腦的結構、原理與維修
- The Reinforcement Learning Workshop
- 從企業級開發到云原生微服務:Spring Boot實戰