• Thanks Gordon. I had expected that implementing the code generation would be complicated, but actually it was relatively easy, since the flattening of the tree was already there. Some results with different watchfaces:

    simpleanalog
    No data file, tree: 420ms
    Tree: 440ms
    Collapsed: 190ms
    Precompiled: 170ms
    
    digitalretro
    No data file, tree: 2830ms
    Tree: 2830ms
    Collapsed: 1490ms
    Precompiled: 1366ms
    
    gtgear
    No data file, tree: LOW_MEMORY,MEMORY
    Tree: 2020ms
    Collapsed: 1150ms
    Precompiled: 1060ms
    

    Precompiling the watchface to draw calls gets about 10% reduction in drawing time after reducing the tree down to an array. Storing all images directly as binary string does not do a lot, on the order of single digit milliseconds. But every little thing counts.

    Would you say replacing a switch with something like this generally would be faster?

    function doA(p){}
    function doB(p){}
    
    for (var c of items){
          switch(c.name){
            case "A": doA(c.param); break;
            case "B": doB(c.param); break;
          }
    }
    // faster than the switch?
    for (var c of items){
         eval('do' + c.name + '(' + c.param + ')');
    }
    

    Absolutely catastrophic security-wise, but probably not really problematic for the bangle. If people start using watchfaces from wherever, maybe input sanitation would be in order.

    Maybe drawing parts of the clock (digital time, weather, status icons) into arraybuffers in an event driven way and only compositing those together on every draw could be faster? At least digital time would only be refreshed once a minute instead of every call like now. Parts could individually change at their own speed without beeing actually redrawn on every refresh. Instead there would be the compositing overhead on every draw...

About

Avatar for halemmerich @halemmerich started