官术网_书友最值得收藏!

  • Delphi High Performance
  • Primo? Gabrijelcic
  • 324字
  • 2021-06-24 19:23:03

Fine-Tuning the Code

I have stated repeatedly that the best way to improve code speed is to change the algorithm.  Sometimes, however, this is just not possible because you are already using the best possible algorithm. It may also be completely impractical as changing the algorithm may require rewriting a large part of the program.

If this is the case and the code is still not running fast enough, we have multiple available options. We can start optimizing the program, by which I mean that we can start changing small parts of the program and replacing them with faster code. This is the topic of the chapter that you are currently reading.

Another option would be to rewrite a part of the program in assembler. Delphi offers quite decent support for that and we'll look into that possibility near the end of this chapter. We can also find a library that solves our problem. It could be written in an assembler or created by a compiler that produces faster code than Delphi—typically we don't care. We only have to know how to link it into our program and that will be the topic of Chapter 8, Using External Libraries.

The last option is to somehow split our problem into multiple parts and solve them in parallel. We'll dig into this approach in Chapters 5 to 7.

But first, fine-tuning the code, or how to make the program run faster with small changes. In this chapter, you'll find:

  • How Delphi compiler settings can affect the program speed
  • Why it is good to use local variables to store intermediate results
  • How to work with the CPU window
  • What happens behind the scenes when you work with different data types
  • How to speed up the code by using RTL functions
  • How to use an assembler to speed up the code
  • How we can make SlowCode run even faster
主站蜘蛛池模板: 威宁| 卫辉市| 龙川县| 兰溪市| 钟祥市| 玛纳斯县| 夏邑县| 江达县| 抚松县| 健康| 双流县| 扶沟县| 高碑店市| 怀远县| 维西| 砚山县| 潼南县| 徐水县| 中西区| 常州市| 宜宾市| 衡水市| 平顶山市| 天全县| 武安市| 泰来县| 兴义市| 出国| 萝北县| 托克托县| 黄平县| 金昌市| 西藏| 阿合奇县| 南华县| 新竹县| 常州市| 宁海县| 平陆县| 凉城县| 丰顺县|