You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Yes, compiled code is out on that :)

    I just did:

    function test() {
      var a = new Uint8Array(10000);
      var t = getTime();
      for (var i=0;i<10000;i++)a[i]=i;
      print(getTime()-t);t = getTime();
      for (var i=0;i<10000;i++){a[i]=i;a[i]=i;}
      print(getTime()-t);t = getTime();
      for (var i=0;i<10000;i++){a[i]=i;a[i]=i;a[i]=i;}
      print(getTime()-t);t = getTime();

    And it came out at:


    So it looks like for a[i]=i it's 0.08ms, so with 75 accesses it's looking like 9ms is in the right kind of ballpark. It's just not that quick I'm afraid.

    It feels like array accesses should be faster - but in fact a lot of that is looking up the variables - for example even doing a;i;i; takes 0.063ms.

    It's something I hope I can make a bit faster soon - maybe by adding some kind of cache... but to be honest Espruino really is never going to be good at flat-out speed.


Avatar for Gordon @Gordon started