Jump to content

Performance Optimization tips.


JackFalcon
 Share

Recommended Posts

Question about setEnabled(false). Is it better performance than visibility = 0 ?

And wondering what is the difference?

If 1 mesh is rotating 10 children, and 5 can be hidden - which is more performant: visibility or setEnabled(false);

I'll test it....

Lots of reading. 

Thanks!  

Link to comment
Share on other sites

Statistics -->great idea<--

Thank you setEnabled(true) insight!

TINY-UPDATES: 

- the code below worked well as first pass rough-in.

RESULTS: performance improvement achieved! (ding).

- Will try setEnabled... on parents

-  -> But had interesting PROBLEM: need parent setEnabled(true) AND children setEnabled(false)???<--

       anyway... : )

- Hello LOD! too.

- Probably date.now all three [hope] (BZ thx).


reloadLevel = function(){
    for(var i=0; i<edges.length; i++){ edges[i].visibility = 1; }
    for(var i=0; i<orbs.length; i++){ orbs[i].visibility = 1; }
    for(var i=0; i<boxes.length; i++){ boxes[i].visibility = 1; }
    for (var i=0; i<tiles.length; i++){ tiles[i].visibility = 1; }
}

unloadLevel = function(){
    for(var i=0; i<edges.length; i++){ edges[i].visibility = 0; }
    for(var i=0; i<orbs.length; i++){ orbs[i].visibility = 0; }
    for(var i=0; i<boxes.length; i++){ boxes[i].visibility = 0; }
    for (var i=0; i<tiles.length; i++){ tiles[i].visibility = 0; }
}

 

Link to comment
Share on other sites

Ok,

Put in TIMESTAMPS ... gotta go.

Thanks to who'ever made dude.

Here is adapted timestamp utility, to easily measure performance anywhere:

//TIMER
var timeStamp = 0;
var currentTimeStamp = 0;
var timeReport = function(testname){
    console.log('TIMESTART: '+testname);
    if(!timeStamp){ timeStamp = new Date().getTime(); }
    return function (testname) {
        currentTimeStamp = new Date().getTime();
        var timeDelta = currentTimeStamp - timeStamp;
        console.log('TIMESTOP: '+testname+' = '+timeDelta);
        timeStamp = null;
    }
}
//EXAMPLE-USAGE-.
// var debugTimeStop = timeReport('START Time Test');
// debugTimeStop('END Time Test');

Statistics pending...

Link to comment
Share on other sites

rudimentary stats... 

TEST DESCRIPTION: rotating parent with gradual increasing number of children(30,60,90) for each rotation, step-interpolation = 0.02, on a closed-circuit track.

BASELINE   NO-PERF-OPS   3 CONTROL-TESTS:

TIMESTART: START-ANIMATION
TIMESTOP: END-ORBIT = 1867
TIMESTART: START-ANIMATION
TIMESTOP: END-ORBIT = 4294
TIMESTART: START-ANIMATION
TIMESTOP: END-ORBIT = 6724

 

OP-TEST-1  visibility = 0    3 COMPARISON-TESTS:

TIMESTART: START-ANIMATION
TIMESTOP: END-ORBIT = 1937
TIMESTOP: END-ORBIT = 4237
TIMESTOP: END-ORBIT = 4679

OP-TEST-1 RESULTS:

Within variance, visibility = 0 for hidden mesh, reduces orbit time ~2 seconds on third rotation (HOO-RAY).

QUESTION: which is better visibility or setEnabled(false)?

Bird should read source code, or...

TEST: replace vis =0 to  setEnable(false) in the same loops...

TIMESTART: START-ANIMATION
TIMESTOP: END-ORBIT = 1917
TIMESTOP: END-ORBIT = 4227
TIMESTOP: END-ORBIT = 4778
 

RESULTS:

Interesting - visibility is slightly faster (within variance). 

Didn't expect that. Bird should read source code.

NOTE: couldn't use setElement(false) at parent level because in context need parent to remain visible, and only children hidden.

NEXT-STEPS: 

Not going to do LOD test, sticking with simple visibility op for the moment.

Instances not applicable.

This is solved. Maybe more PERFOPS later.

Hope this helps someone.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...