- Delphi High Performance
- Primo? Gabrijelcic
- 253字
- 2021-06-24 19:23:00
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.
推薦閱讀
- 同步:秩序如何從混沌中涌現(xiàn)
- 公有云容器化指南:騰訊云TKE實(shí)戰(zhàn)與應(yīng)用
- Test-Driven Development with Mockito
- Lean Mobile App Development
- Hadoop大數(shù)據(jù)實(shí)戰(zhàn)權(quán)威指南(第2版)
- Flutter Projects
- 大數(shù)據(jù)治理與安全:從理論到開源實(shí)踐
- 探索新型智庫(kù)發(fā)展之路:藍(lán)迪國(guó)際智庫(kù)報(bào)告·2015(下冊(cè))
- 區(qū)塊鏈技術(shù)應(yīng)用與實(shí)踐案例
- Unreal Engine Virtual Reality Quick Start Guide
- 智慧城市中的大數(shù)據(jù)分析技術(shù)
- 大數(shù)據(jù)測(cè)試技術(shù):數(shù)據(jù)采集、分析與測(cè)試實(shí)踐(在線實(shí)驗(yàn)+在線自測(cè))
- 數(shù)據(jù)之美:一本書學(xué)會(huì)可視化設(shè)計(jì)
- 工業(yè)大數(shù)據(jù)融合體系結(jié)構(gòu)與關(guān)鍵技術(shù)
- 深入理解Flink:實(shí)時(shí)大數(shù)據(jù)處理實(shí)踐