Hi Folks,
I am optimizing a code for speed in gpc. Let me share some strange observations of mine.
I have two vectors of size N and M. I need to perform a not too complex calculation between all the elements (NxM) two times. I thought I dump the result into an array of NxM and second time just read the array back and this should save me time on the expense of memory. In fact this is about 50% slower than generating the result dynamically twice!!! Is it normal in gpc? Why the handling of large arrays are so slow?
The speed of the loops are also different by about 50% depending on the following alternative styles:
1)
for i:= 1 to 10 do whatever;
2)
const one=1; ten=10; ..
for i:= one to ten do whatever;
3)
var one, ten:integer; ..
one:=1; ten:=10; for i:= one to ten do whatever;
4)
var one, ten:integer; ..
one:=1; ten:=10; for i:= one to ten * one do whatever;
The real code use much longer loops in a nested fashion of course, so the speed difference is significant. Are there other speed-related tricks?
I am using an outdated version of gpc (2.0) on IRIX. Are these things any better in a more recent release?
Cheers,
miklos