Advertisement

Code optimisation

Started by January 28, 2000 06:47 AM
13 comments, last by Spura 24 years, 10 months ago
Ah at last a delphi question I can answer.
Delphi aligns ALL data to the 32bit boundaries unless you turn that off. So be careful when reading unaligned data from disk.
quote:

Actually the Borland C++ compiler and Object Pascal compiler have the same back-end. That is to say, they share intermediate code representation. There is no speed difference between C++ and Object Pascal. Perceived speed differences in Delphi versus other Windows Programs based in C++, come more from the fact that the VCL library Delphi uses for its windows functions is slower than equivalent functionality granted by, for example, MFC. For proof benchmark a C++ Builder program versus a Delphi program. They both share the VCL library for their windows functionality.

By the same logic, as long as you can translate I-Shaolin''s comments into Pascal equivalent form, you can still benefit.

Also don''t forget things like table driven logic, and taking advantage of temporal and spatial locality in code and data.


What ?!
Do you actually code in C/C++ if yes you would know that the C language allows you construcs that can be compiled into much faster assembly code that it could be possible using pascal syntax, because it doesn''t allow you to use these constructs.

C ya
Lightsaber
Advertisement
32 bit data alignment speeds things up, because the x86 family of processors from the 386 on, just access memory on 32 bit boundaries better. You can read up on the specs to get the details, but it doesn''t have anything to do with the cache, as the cache will read a whole line whether or not you access 1 byte or 4 bytes.

quote:
What ?!
Do you actually code in C/C++ if yes you would know that the C language allows you construcs that can be compiled into much faster assembly code that it could be possible using pascal syntax, because it doesn''t allow you to use these constructs.

To your question, a question: Have you programmed in Object Pascal? I can''t think of a single C++ construct that doesn''t have an equivelant in Object Pascal.

More to the point, I think you misunderstand the premise underlying my statement. The C++ Builder and Delphi compilers share the same intermediate code representation! C++ and Object Pascal constructs are being reduced to the same form. And then transformed into object code.
Now, any online files about this?
This is the only web page I''ve found that is devoted to optimisation:
http://www.ontek.com/mikey/optimization.html

Other online sources often will mention optimal methods in passing, so your best bet is to just start reading *everything*.

Hardcopy-wise, you can learn alot of source code optimisation techniques from books on computer architecture and compiler design.

This topic is closed to new replies.

Advertisement