Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / memblock vs dot vs dot with unlocked pixels [speed test]

Author
Message
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 28th Dec 2011 12:28 Edited at: 28th Dec 2011 12:33
Hi guys,

I've often heard that memblocks are super fast but I don't know anyone who's actually gone out of their way to test their speed. So I pulled a fractal program from the snippets board, and did some experiments and optimization on the code I found. I quickly discovered that moving the sync command out of the loop dramatically sped the program up by as much as 10 times. I then proceeded to test memblocks against the dot command in three different ways.

1. Dot command without unlocking and locking pixels
2. Dot command with unlocking and locking pixels
3. Memblock command

The results are as follows:

1. DOT command without unlocking = 610ms to 630ms
2. DOT command with unlocking = 157ms to 177ms
3. Memblock method = 149ms to 151ms

So it appears that memblocks are indeed a little bit faster.

But the question is, can you make this program run any faster?

Memblock version


Dot with Unlocked pixels


Dot without unlocked pixels


My system specs here:
Max P
14
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 28th Dec 2011 17:25 Edited at: 28th Dec 2011 17:30
Putting the lock pixels/unlock pixels outside the y loop will be a bit faster.


Results:
1. DOT command without unlocking = 1051 ms
2. DOT command with unlocking = 208 ms
3. Memblock method = 210 ms
4. DOT command with unlocking (lock outside loop) = 201 ms

Quote: "So it appears that memblocks are indeed a little bit faster."

Seems like locking the pixels is faster for me.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 28th Dec 2011 20:42
How does Occlusion culling work¿

How about fastsync¿

WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 28th Dec 2011 21:35
Some interesting results.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 28th Dec 2011 22:41


With stuff like this, you can potentially save yourself some call overhead by calc'ing the value(s) once.

eg



in-lining the abs function might be better here,



you could try re-arrangement the comparisons as there are bound to be some variations that are more optimal in DBpro than others. Boolean expressions might be a better, just depends on the compiler again.

The repeat until can probably be replaced with a For/next and unrolled a bit.



by stepping in groups of 2 say, you can avoid some more loop overhead. Groups of 4 is often a happy medium between size and loop overhead





An array is probably better for the colour table than a select case, in particular when Dbpro doesn't have precalc of functions. So RGB() is being executed, even though the function is producing a constant result...

So this stuff





etc.

Login to post a reply

Server time is: 2024-04-25 17:43:41
Your offset time is: 2024-04-25 17:43:41