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:
1.89215660095
2.79538631439
3.63432979583
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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes, compiled code is out on that :)
I just did:
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;
takes0.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.