Kodewerx

Our culture has advanced beyond all that you could possibly comprehend with one hundred percent of your brain.
It is currently Mon Mar 18, 2024 9:17 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Nov 08, 2010 8:58 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:26 pm
Posts: 3768
Title: All in a day's work.
When I first began re-re-writing Syndrome in JavaScript, I wasn't sure what to expect so far as rendering speed. In C, the first stage in Mega Man 7 could be rendered in 0.009 seconds on a ten-year-old Athlon XP 2600. That's incredibly fast. How does it compare in JavaScript?

Well ... the first attempt was not all that impressive. In fact, it was downright disheartening at 2.023 seconds on Gecko 1.9.1 running on a 2.8 GHz Core 2 Duo.. After some major refactoring, it got a good bit faster at 0.486 seconds on Gecko 1.9.2. Still a few orders of magnitude away from the raw performance of C.

By doing nothing more than upgrading to Gecko 2.0beta, The same code base renders in 0.264 seconds. Removing just a single for-loop that pre-filled an array with zeros brought it down to 0.188 seconds. Hacking the pixel-pushing code from plain old JavaScript arrays to the brand new JavaScript Typed Arrays increased the speed even further, down to 0.16 seconds. And doing the same kind of hack on the palette cache brought it down to the current 0.15 seconds.

At this point, it is still ~17x slower than the raw C drawing code. But there is still many more opportunities for optimization. Converting many of the array buffers to JS Typed Arrays will likely help dramatically, still. The ROM buffer would probably show the biggest improvement, along with the accessor methods for pulling different data sizes from the buffer. And Web Workers can push the actual rendering into background threads making the actual drawing look like it completes instantly. And of course, for pure überspeed, writing a dynamic library in C that does pixel-pushing, and calling into it with js-ctypes.

Still, 150ms to draw a 4864x768 bit-map using only JavaScript is incredible! Gotta hand it to Mozilla, they've done really well. And it's only going to get faster! Gecko 2.0 is still just in beta (planned release is sometime in early 2011). It won't have a great deal of performance improvements by then, but there's still planned work that will go into the JavaScript engine in the future. It's a good time to be a web developer transitioning to desktop application development. ;)

_________________
I have to return some video tapes.

Feed me a stray cat.


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 08, 2010 9:17 pm 
Offline
Krew (Admin)
Krew (Admin)
User avatar

Joined: Sun Oct 01, 2006 9:46 pm
Posts: 2331
Location: *poof*
Title: The Mad Hacker
_awesome_

_________________
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group