Results 1 to 9 of 9
  1.    #1  
    Wow... I just discovered how slow the Pre's webkit rendering is. At least, unless I miss something.

    I have been working on a BlinkenLights renderer for Screamager today.

    Once I got it to work I wanted to improve the framerate. Let's start with the original approach:

    The dot matrix screen is a grid made out of 18 divs that are rows of pixels. Each div contains 26 divs that are the individual dots on the screen.

    The original 'renderer' would take a 2 dimensional array. It contains 18 arrays that each hold 26 bits that can be zero or one. I would loop through these arrays and set or unset a classname of 'on'. this makes the whole thing kind of work like a CRT. it draws each line, pixel by pixel.

    Now to speed this up I tried to pre-generate all frames as complete chunks of HTML. All I'd need to do now is replace $('ledfield').innerHTML with a new chunk for each frame. It all worked fine and on the emulator I saw a HUGE speed increase. I got over 10fps which makes it look pretty awesome.

    After putting this new test version on the phone I saw..... NO DIFFERENCE!!!

    This means that 'reinitializing each pixel one by one for every frame' or banging the whole frame in at once runs at... the exact SAME speed.

    Needless to say, I'm a bit disappointed....

    Let me show the code for the two approaches:

    render a frame the old way (for each frame)

    Code:
    		function renderFrame(displayArray, deadLines) {
    			if(deadLines === null) {
    				deadLines = [];
    			}			
    			var i=0;
    			var j=0;
    			for(j=0;i<18;i++) {
    				var px = pixels[i];
    				j=0;
    				if(!in_array(i, deadLines)) {
    					for(;j<26;j++) {
    
    						className = px[j].className;
    						if(displayArray[i][j] == 1) {
    							if(className !== 'led on') {
    								px[j].addClassName('on');
    							}
    						}
    						else {
    							if(className === 'led on') {
    								px[j].removeClassName('on');
    							}
    						}
    					}
    				}
    			}
    		}
    render a frame the new fast way (for each frame)

    Code:
    $('ledfield').innerHTML = frames[frameNumber];
    (where frames is an array containing a chunk of HTML for each frame)

    No difference people. No difference. ARGH!!!!!!
    My shiny new TouchPad apps: Scientific RPN Calculator HD - Screamager HD
  2. #2  
    pretty hard to imagine nested loops taking the same time to execute as one line of code..
    Check out GetMeVino!
  3.    #3  
    mt3ck I know! And on the emulator you DO see the huge speed increase so I know the strategy actually has an effect.

    On the phone however there's absolutely no visible difference.
    My shiny new TouchPad apps: Scientific RPN Calculator HD - Screamager HD
  4. kesne's Avatar
    Posts
    471 Posts
    Global Posts
    491 Global Posts
    #4  
    Quote Originally Posted by TheMarco View Post
    mt3ck I know! And on the emulator you DO see the huge speed increase so I know the strategy actually has an effect.

    On the phone however there's absolutely no visible difference.
    It's because the emulator is MUCH faster than the pre, which is an issue with testing on it. My suggestion: test everything on the pre, the emulator is full of infinite sorrows (Reference to "You Suck at Photoshop").
  5.    #5  
    I know the emulator is faster. What I tried to say is: the optimization WORKS which is proven by the speed increase on the emulator. Therefore I expected a lesser speed increase on the phone, but... I still expected an increase. Unfortunately I got absolutely no visible difference.
    My shiny new TouchPad apps: Scientific RPN Calculator HD - Screamager HD
  6. #6  
    Is there any way for you to benchmark the two approaches and see if there is some smaller difference that you're just not seeing?

    Even a tiny gain might make a difference in some settings.
  7. s219's Avatar
    Posts
    498 Posts
    Global Posts
    1,008 Global Posts
    #7  
    (where frames is an array containing a chunk of HTML for each frame)

    No difference people. No difference. ARGH!!!!!!
    I guess I'd like to see this "chunk of HTML" to see what exactly we're comparing to.

    But if there is no difference (as in the timing is exactly the same) I might suspect there was a mixup somehow, or you unknowingly didn't put the new version on the device, or some other mistake happened. Don't ask me why I would suggest such a thing.....

    Can you load this up into a web page and benchmark it through the browser with both approaches?
  8. s219's Avatar
    Posts
    498 Posts
    Global Posts
    1,008 Global Posts
    #8  
    BTW, one possibility I have seen before is that the on-device performance is so slow, that some other aspect of running the app is swamping both the slow code and the fast code, so that they appear about the same. Make sure some other aspect of the app isn't hogging all the time. For example, approach 2 could be twice as fast as approach 1, but if some other part of the app is taking 98% of the CPU time, then both approaches will have a similar relative effect (peanuts).
  9.    #9  
    This can't be it. I guess I wasn't clear.

    Let's say the first version gave me 10fps on the emulator and 5fps on the phone.

    Then I do an improved version and I get 15fps on the emulator. That can only mean one thing: the new code is faster.

    Then on the phone you'd expect to gain a few fps as well which isn't happening.

    There are no 'other aspects' because there's only one routine running to animate. There's nothing else going on in the background.

    I also verified that I can be SURE the app on the phone actually got updated with the new code by making other obvious changes (such as putting in a new animation).

    For example, approach 2 could be twice as fast as approach 1, but if some other part of the app is taking 98% of the CPU time, then both approaches will have a similar relative effect (peanuts).
    If this were true the speed should stay the same on the emulator as well.

    In another desperate attempt I changed the markup from a DIV based structure into a table. I figured maybe that would speed things up. Again, no gain. In this case both the emulator and the phone didn't show any difference.
    My shiny new TouchPad apps: Scientific RPN Calculator HD - Screamager HD

Posting Permissions