valueerror Posted October 9, 2014 Share Posted October 9, 2014 i dont know about the internals of phaser but i could imagine that using collision groups instead of letting everything collide with everything and filter the relevant infos in the begincontact event would be faster because phaser/p2 doesnt need to check everything against everything.. right or totally wrong because collisiongroups create an aditional overthead? Link to comment Share on other sites More sharing options...
valueerror Posted October 12, 2014 Author Share Posted October 12, 2014 i was just wondering because i am searching for everything possible to optimize my code for speed and i just don't know where to look.. what definitely is missing is a sticky thread called "phaser performance guide - tips and tricks" or something similar where we could summarize our experiences Link to comment Share on other sites More sharing options...
Wavertron Posted October 14, 2014 Share Posted October 14, 2014 Its a good question and a good suggestion. But I don't have any quick answers for you sorry :/If you really need to tune a lot, you're prob best to build discrete test cases where you can tweak only a few variables and observe the results. Once proven only then integrate into your game. You could also try digging into the guts of the p2 code or maybe check with the author Schteppe for a quick answer Link to comment Share on other sites More sharing options...
valueerror Posted October 14, 2014 Author Share Posted October 14, 2014 thank you! i've done that but i've seen no difference (but this is probably due to my test devices beeing very performant) Link to comment Share on other sites More sharing options...
David Posted October 15, 2014 Share Posted October 15, 2014 If you want to know if there is any meaningful difference, a bench mark can help:console.time('bench-mark1');//do test case 1 N timesconsole.timeEnd('bench-mark1);console.time('bench-mark2');//do test case 2 N timesconsole.timeEnd('bench-mark2);I usually run between 1k and 100k iterations depending on the test. I keep the setup code in a snippet in Chrome devtools. Note that you want to be sure you're test case isn't too simple. The optimizer can kick in and take unexpected shortcuts that give readings that don't reflect what you can expect in actual usage. If I have nothing else to do, I'll add 1 to an accumulator. Also, if you want to benchmark some non-Phaser dependent, jsperf is awesome. Bonus: Here's a bunchmark of mine that had some surprising results:var runCount = 10000000;var list = [];var temp = 0;//setupfor(var x = 0; x < runCount; x++) { list[x] = x;}console.time('bench1');for(var x = 0; x < runCount; x++) { temp += list[x];}console.timeEnd('bench1');temp = 0;console.time('bench2');underscore.each(list, function(item) { temp += item;});console.timeEnd('bench2');temp = 0;console.time('bench3');lodash.each(list, function(item) { temp += item;});console.timeEnd('bench3');temp = 0;console.time('bench4');list.forEach(function(item) { temp += item;});console.timeEnd('bench4');This assumes you're got both lodash and underscore assigned in noConflict tot their respective variables. valueerror 1 Link to comment Share on other sites More sharing options...
valueerror Posted October 22, 2014 Author Share Posted October 22, 2014 thx ! this is an interesting way to test performance.. i will get back to this the nex time i am profiling my game as for the collision groups.. still no answer - but - i deciced to go with collisiongroups because they are very very useful and i couldn't make out any difference in performance with our without them... same goes for impactEvents.. next time i'm going to use them because working with onBeginContact only just isn't that convenient... Link to comment Share on other sites More sharing options...
Recommended Posts