KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In Delphi you can speed up your code by passing parameters as const , e.g. function A(const AStr: string): integer; //or function B(AStr: string): integer; Suppose both functions have the same code inside, the speed difference between them is negligible and I doubt it can even be measured with a cycle-counter like: function RDTSC: comp; var TimeStamp: record case byte of 1: (Whole: comp); 2: (Lo, Hi: Longint); end; begin asm db $0F; db $31; mov [TimeStamp.Lo], eax mov [TimeStamp.Hi], edx end; Result := TimeStamp.Whole; end; The reason for this is that all the const does in function A is to prevent the reference count of AStr to be incremented. But the increment only takes one cycle of one core of my multicore CPU, so... Why should I bother with const ?
Tags (comma-separated)
Save Edits
Cancel