You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • Espruino test (uploaded from editor pane and invoked with exec() in the console on Espruino Wifi):

    var C = {
     OLED_WIDTH                 : 128,
     OLED_CHAR                  : 0x40,
     OLED_CHUNK                 : 128
    }, WIDTH = 128, HEIGHT = 64;
    function exec() {
      var buf = new Uint8Array((WIDTH*HEIGHT) / 8), bLen = buf.length;
      var chunk = new Uint8Array(C.OLED_CHUNK+1), cLen = chunk.length;
      console.log("buf: " + bLen + " - chunk: " + cLen);
      chunk[0] = C.OLED_CHAR;
      var p, pe, c1, t10, t11, slice, c2, t20, t21, cL = C.OLED_CHUNK;
      for (p=0; p < bLen; p += C.OLED_CHUNK) { pe = p + C.OLED_CHUNK;
    t10 = new Date().getTime(); for (c1 = 0; c1 < 100; c1++) {
    chunk.set(new Uint8Array(buf.buffer,p,cL), 1);
    } t11 = new Date().getTime();
    t20 = new Date().getTime(); for (c2 = 0; c2 < 100; c2++) {
    chunk.set(buf.slice(p, pe), 1);
    } t21 = new Date().getTime();
        console.log(p+"-"+(pe)+": " + ((t21 - t20) / (t11 - t10)));
      }
    }
    

    Console:

     1v87 Copyright 2016 G.Williams
    >exec()
    buf: 1024 - chunk: 129
    0-128: 4.07852737698
    128-256: 4.52856306801
    256-384: 5.24940776218
    384-512: 5.27483808673
    512-640: 6.57535412290
    640-768: 8.54367417763
    768-896: 7.12319090028
    896-1024: 7.51280680688
    

    Interesting is the relatively great variation... so I run it with HEIGHT = 128 - double the original buffer... and variation is worse:

     1v87 Copyright 2016 G.Williams
    >exec()
    buf: 2048 - chunk: 129
    0-128: 2.42377434903
    128-256: 6.01698313765
    256-384: 3.10307471306
    384-512: 5.11592931261
    512-640: 8.91618411518
    640-768: 9.59016115959
    768-896: 8.67426096522
    896-1024: 8.14185429263
    1024-1152: 13.84030717299
    1152-1280: 13.78322895572
    1280-1408: 8.70759501664
    1408-1536: 10.94154115774
    1536-1664: 22.54689730282
    1664-1792: 12.00001317154
    1792-1920: 34.27794204212
    1920-2048: 16.76400105146
    

    Have no answer why...

About

Avatar for allObjects @allObjects started