Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, Nymphodora, Quad, TipmyPip, Imhotep), 852 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
performence boost for your project #329588
06/21/10 12:49
06/21/10 12:49
Joined: Oct 2002
Posts: 806
Zapan@work Offline OP
User
Zapan@work  Offline OP
User

Joined: Oct 2002
Posts: 806
You can improve the performence of your project when not using the engine intern sheduler. Instead just use linked lists. We use this for our own projects (zombies etc.) wink

without linked-list:


with linked-list:


//////////////////////////////////////////////////////////////////////
// Link List Example
//--------------------------------------------------------------------
// Modul : Entity helper funcs
// Created : crew51 GbR : 2010-06-21
// $Id$
//--------------------------------------------------------------------
// todo:
/*

*/
//--------------------------------------------------------------------

#define USE_LINK_LIST

#include <acknex.h>
#include <default.c>

// Header
ENTITY* pEmeter_first;
ENTITY* pEmeter_last;

void ent_listFuncFrm(ENTITY* p);

#define ent_prevListObj skill96
#define ent_nextListObj skill97

//--------------------------------------------------------------------
// Add an object to the list
//--------------------------------------------------------------------
void ent_listAdd(ENTITY* p, ENTITY** first, ENTITY** last)
{
if (*first == NULL) {
*first = p;
*last = p;
return;
}

(**last).ent_nextListObj = p;
p.ent_prevListObj = *last;
*last = p;
}

//--------------------------------------------------------------------
// Remove from the entity list
//--------------------------------------------------------------------
void ent_listRemove(ENTITY* p, ENTITY** first, ENTITY** last)
{
//we're the last one
if (p.ent_nextListObj == NULL) {
if (p.ent_prevListObj != NULL) {
*last = p.ent_prevListObj;
(**last).ent_nextListObj = NULL;
} else {
*last = NULL;
}
}

//we're the first one
if (p.ent_prevListObj == NULL) {

if (p.ent_nextListObj != NULL) {
*first = p.ent_nextListObj;
(**first).ent_prevListObj = NULL;
} else {
*first = NULL;
}
}

//in the middle
if ((p.ent_nextListObj != NULL) && (p.ent_prevListObj != NULL)) {
ENTITY* p1 = p.ent_prevListObj;
ENTITY* p2 = p.ent_nextListObj;

p1.ent_nextListObj = p2;
p2.ent_prevListObj = p1;
}

}

//--------------------------------------------------------------------
// Test func for cube
//--------------------------------------------------------------------
void cube_rotate(ENTITY* p)
{
p.pan += 23 * time_step;
}

//--------------------------------------------------------------------
// Run all funcs
//--------------------------------------------------------------------
void ent_listExec(ENTITY* first, void* f)
{
ent_listFuncFrm = f;

ENTITY* p = first;
while (p != NULL) {
my = p;
you = NULL;

ent_listFuncFrm(p);
p = p.ent_nextListObj;

my = NULL;
you = NULL;
}
}

void cube_func()
{
while(1) {
wait(1);
my.pan += 23 * time_step;
}

}
void main()
{
warn_level = 99;
level_load(NULL);

wait(2);

pEmeter_first = NULL;
pEmeter_last = NULL;

int i;
VECTOR v;
ENTITY* p;
vec_set(v.x, nullvector);


for (i = 0; i < 1000; i ++) {
#ifdef USE_LINK_LIST
p = ent_create(CUBE_MDL,v.x,NULL);
ent_listAdd(p, &pEmeter_first, &pEmeter_last);
#else
p = ent_create(CUBE_MDL,v.x,cube_func);
#endif

}

#ifdef USE_LINK_LIST
while (1) {
wait(1);
ent_listExec(pEmeter_first, cube_rotate);

//remoce cubes...
/*
vec_set(v.x, vector(500, 0, 0));
vec_rotate(v.x, camera.pan);
vec_add(v.x, camera.x);

c_trace(camera.x, v.x, IGNORE_SPRITES);
if (trace_hit) {
draw_point3d(hit.x,vector(0,0,255),100,5);
if ((key_space) && (hit.entity != NULL)) {
ent_listRemove(hit.entity, &pEmeter_first, &pEmeter_last);
ent_remove(hit.entity);
}
}


if (pEmeter_first != NULL) {
draw_point3d(pEmeter_first.x,vector(1,255,255),100,15);
}
if (pEmeter_last != NULL) {
draw_point3d(pEmeter_last.x,vector(255,255,1),100,15);
}
*/

}
#endif

}

Re: performence boost for your project [Re: Zapan@work] #329599
06/21/10 13:30
06/21/10 13:30
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Very clever. I'll consider something like this in the future!

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: performence boost for your project [Re: JibbSmart] #329605
06/21/10 14:04
06/21/10 14:04
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Wow, this is so much faster than actions? I would have always guessed something like a linked list would be faster than using caroutines, but only like 10fps faster, even for so many entities, and not 40fps. Thanks for the hint! laugh

grin But I couldn't help giggling a bit after seeing this code again. wink

Re: performence boost for your project [Re: Lukas] #329611
06/21/10 14:28
06/21/10 14:28
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
it would be interesting to know where the overhead comes from since internally the scheduler also only uses some list with the functions. a wait() also stores/restores the local variables but does this take so much time?

Re: performence boost for your project [Re: ventilator] #329615
06/21/10 15:01
06/21/10 15:01
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
so this is for running only one fuction for entites with same behaviour instead of running the same action for them all?

if i got it right, it's sounds very logical.

if i got it wrong someone please enlighten me.


3333333333
Re: performence boost for your project [Re: Quad] #329617
06/21/10 15:04
06/21/10 15:04
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
You either got it right, or we both got it wrong. grin

Re: performence boost for your project [Re: Lukas] #329618
06/21/10 15:07
06/21/10 15:07
Joined: Oct 2002
Posts: 806
Zapan@work Offline OP
User
Zapan@work  Offline OP
User

Joined: Oct 2002
Posts: 806
You can use many diffrent functions for any kind of entity... Just give it a try. We've checked this withs our old glider game and have ~40 fps in all levels...

Re: performence boost for your project [Re: Zapan@work] #329675
06/21/10 20:22
06/21/10 20:22
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
yeah but like that all the advantages of having coroutines are gone, like local variables being restored after a wait.

Re: performence boost for your project [Re: Joey] #330199
06/26/10 09:37
06/26/10 09:37
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Originally Posted By: Joey
yeah but like that all the advantages of having coroutines are gone, like local variables being restored after a wait.

What sort of coroutines fell off, too?
Lokal variabels are not such a loss, if you have been familiar with programming in wdl, right?
Skills are still valid, as far as I understood this.

The question is, is it worth the hassle in your specific project...


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1