PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

OOP's procs calls vs Procs calls

Here is some testings for subj:
For object testing I used:
Code:

#class Tobj
public(
iter$
);

private nproc Create
iter$ = args$[0];
end;

public proc makeIter()
iter$++;
end;

#endclass

proc main
#object Tobj obj$(0);
t$ = Tick();
while ((Tick() - t$) < 10000)
obj.makeIter();
end;
showMessage(str(obj.iter$));
end;

And for the simple proc call:
Code:

proc TestIter(i$)
i$++;
end;

proc main
i$ = 0;
t$ = Tick();
while ((Tick() - t$) <= 10000)
TestIter(&i$);
end;
showMessage(str(i$));
end;

Here are the results (on a ASUS A620):
Object calls : 188469 iterations
Simple proc calls: 336212 iterations (It almost two times faster :( ) (especially if you use that in game's WM_TIMER event)
The problem is that object calls are dynamically processed while normal calls are pre-processed at compile time. This makes a huge difference in speed. I cannot make object calls pre-processed at compile time due to the fact that variables can point to different object class at anytime while running.

But, let me think about it I will see what I can do. I might find a better solution.

I am very busy trying to optimize the gameapi at this time, I will have to put it on the list of things to do.
I was able to optimize the object call by a great deal, it won't be as fast as a standard call but it is faster than before.

NB: The speed in the following table is based on a debug build of PPL and not a release build. (The speed will be a lot faster in release build).

Original speed on PC: 1,664,594
New speed on PC: 2,334,793