|Posted : Tuesday, 08 March 2011, 15:29|
|Hurray!! Finally a blog that I can nick content from, each Friday |
|Posted : Tuesday, 08 March 2011, 15:35|
|Wow, I am impressed with how well its working on Firefox now. Was there anything special you did to do that, or was it just a case of optimising what you had already?|
|Posted : Tuesday, 08 March 2011, 16:07|
|The games are now embedded within an iFrame on PMC. This means that FireFox doesn't render the rest of the page underneath underneath the canvas such as box-shadows or gradients (which is was doing).|
Secondly I profiled the compilation process and found two main issues. First I was using concat as a clean way to join two arrays together because it's very elegant to do so. However it's _much_ cheaper to iterate over an array and manually push each element onto the other. Turns out you should only use concat if you actually need a new copy of the array, which I didn't.
The second thing that was taking a lot of time was 'Array.prototype.slice(arguments)' which is the way suggested online to turn an 'arguments' object into an Array object (for those who don't know the arguments object is a fake array that contains all of the parameters passed into a function, but the trouble is that it's not actually a real array).
Using slice is fast for copying large arrays however it's very rare that you have more then 10 parameters passed into a function. With very small arrays (less then 10 items) it's much faster to just make a new array and push each element onto it.
Finally when you run JS the page will freeze until the JS has finished running. This is because no event's can run, because they can trigger more JS (which the running JS is blocking). This also blocks things like gif animations and JQuery fades. The solution is to use 'setTimeout' to run your code as multiple functions seperated by a couple of milliseconds.
The Quby compiler now uses a special library (called util.future) which I wrote for running multiple functions automatically with setTimeout (it's only about 100 lines). I also changed the front-end of the compiler (only another 100 lines) so it now breaks up the high level parts into seperate function calls, each seperated by 10 milliseconds of breathing space.
In short this means the Quby compiler locks the browser up for much shorter periods of time, allowing the browser to smoothly fade into the compilation process and then fade out.
|Posted : Wednesday, 09 March 2011, 03:51|
|Your blog is void and empty. ^ Post that to your blog!|
|Posted : Wednesday, 09 March 2011, 05:04|
|My brother was supposed to write the first blog post last Sunday. If he doesn't get it done within a few hours I'll post that as our first.|
Otherwise I'll write that up and post it laterz in the week.
|Posted : Wednesday, 09 March 2011, 07:53|
|First post is done! Expect a detailed JS game optimization post in a few days.|
|Posted : Wednesday, 09 March 2011, 08:15|