Build fast, scalable, and high performing applications with Delphi
Key Features
Build efficient and concurrent applications in Delphi with focused examples
Identify performance bottlenecks and apply the correct algorithm to increase the performance of applications.
Delve into parallel programming and memory management to optimize your code
Book Description
Delphi is a cross-platform Integrated Development Environment (IDE) that supports rapid application development for Microsoft Windows, Apple Mac OS X, Google Android, iOS, and now Linux with RAD Studio 10.2. This book will be your guide to build efficient high performance applications with Delphi.
The book begins by explaining how to find performance bottlenecks and apply the correct algorithm to fix them. It will teach you how to improve your algorithms before taking you through parallel programming. You'll then explore various tools to build highly concurrent applications.
After that, you'll delve into improving the performance of your code and master cross-platform RTL improvements. Finally, we'll go through memory management with Delphi and you'll see how to leverage several external libraries to write better performing programs.
By the end of the book, you'll have the knowledge to create high performance applications with Delphi.
What you will learn
Find performance bottlenecks and easily mitigate them
Discover different approaches to fix algorithms
Understand parallel programming and work with various tools included with Delphi
Master the RTL for code optimization
Explore memory managers and their implementation
Leverage external libraries to write better performing programs
Who This Book Is For
This book is for Delphi developers who would like to build high performance applications with Delphi. Prior knowledge of Delphi is assumed.
Author(s): Primož Gabrijelčič
Publisher: Packt
Year: 2018
Language: English
Pages: 330
City: Birmingham, United Kingdom
Cover......Page 1
Copyright and Credits......Page 4
Packt Upsell......Page 5
Contributors......Page 7
Table of Contents......Page 9
Preface......Page 13
Chapter 1: About Performance......Page 20
What is performance?......Page 21
Algorithm complexity......Page 22
Big O and Delphi data structures......Page 26
Data structures in practice......Page 30
Mr. Smith's first program......Page 35
Looking at code through the Big O eyes......Page 38
Don't guess, measure!......Page 41
Profiling with TStopwatch......Page 42
Profilers......Page 49
AsmProfiler......Page 50
Sampling Profiler......Page 58
AQTime......Page 60
Nexus Quality Suite......Page 63
Summary......Page 66
Chapter 2: Fixing the Algorithm......Page 68
Responsive user interfaces......Page 69
Updating a progress bar......Page 70
Bulk updates......Page 73
Virtual display......Page 77
Caching......Page 81
Dynamic cache......Page 84
Speeding up SlowCode......Page 90
Summary......Page 92
Chapter 3: Fine-Tuning the Code......Page 94
Delphi compiler settings......Page 95
Code inlining control......Page 96
Optimization......Page 97
Record field alignment......Page 98
Assertions......Page 101
Range checking......Page 102
Extracting common expressions......Page 104
The helpful CPU window......Page 106
A plethora of types......Page 108
Simple types......Page 109
Strings......Page 110
Arrays......Page 112
Records......Page 114
Classes......Page 118
Optimizing method calls......Page 119
Parameter passing......Page 120
Method inlining......Page 125
The magic of pointers......Page 127
Going the assembler way......Page 132
Returning to SlowCode......Page 134
Summary......Page 136
Chapter 4: Memory Management......Page 137
Optimizing strings and array allocations......Page 138
Memory management functions......Page 142
Dynamic record allocation......Page 144
FastMM internals......Page 149
Memory allocation in a parallel world......Page 153
Replacing the default memory manager......Page 158
ScaleMM......Page 165
TBBMalloc......Page 166
Fine-tuning SlowCode......Page 168
Summary......Page 170
Chapter 5: Getting Started with the Parallel World......Page 172
Processes and threads......Page 173
When to parallelize the code?......Page 175
Most common problems......Page 176
Never access UI from a background thread......Page 177
Simultaneous reading and writing......Page 180
Sharing a variable......Page 182
Synchronization......Page 186
Critical sections......Page 187
Other locking mechanisms......Page 193
A short note on coding style......Page 199
Shared data with built-in locking......Page 200
Interlocked operations......Page 202
Object life cycle......Page 205
Communication......Page 208
Windows messages......Page 209
Synchronize and Queue......Page 213
Polling......Page 214
Performance......Page 216
Third-party libraries......Page 217
Summary......Page 219
TThread......Page 220
Advanced TThread......Page 226
Setting up a communication channel......Page 229
Sending messages from a thread......Page 233
Implementing a timer......Page 236
Summary......Page 241
Chapter 7: Exploring Parallel Practices......Page 243
Tasks and patterns......Page 244
Variable capturing......Page 245
Tasks......Page 247
Exceptions in tasks......Page 250
Parallelizing a loop......Page 253
Thread pooling......Page 257
Async/Await......Page 258
Join......Page 262
Join/Await......Page 265
Future......Page 269
Parallel for......Page 271
Pipelines......Page 277
Creating the pipeline......Page 279
Stages......Page 282
Displaying the result and shutting down......Page 286
Summary......Page 287
Chapter 8: Using External Libraries......Page 289
Using object files......Page 290
Object file formats......Page 292
Object file linking in practice......Page 294
Using C++ libraries......Page 298
Using a proxy DLL in Delphi......Page 304
Summary......Page 307
About performance......Page 310
Fixing the algorithm......Page 312
Fine-tuning the code......Page 313
Memory management......Page 315
Getting started with the parallel world......Page 317
Working with parallel tools......Page 320
Exploring parallel practices......Page 321
Using external libraries......Page 322
Final words......Page 323
Other Books You May Enjoy......Page 325
Index......Page 327