chunks of an Uint8Array #652
Replies: 14 comments
-
Posted at 2016-11-23 by @gfwilliams Looks like it's that In the browser:
It's one of those times where I can't help thinking that Espruino does the more sensible thing, but it's not compliant with the spec. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @gfwilliams Ahh, and I just realised - the module itself that you copied that code from is perfectly JS compliant and fine. The problem is that |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @allObjects How about... (corrected):
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @MaBecker thanks - I was so focused on chunk.set :-( btw : The code of module SSD1306 if the fastest i have found so far - great work ! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @MaBecker Oh yeah - that works too - thanks allObjects |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @gfwilliams @allObjects there is a slight problem with that:
Basically the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @allObjects edited... (and see post #10) In test code In Chrom inspec/debug console:
Found no complaint on the Web about this violation... Write a compiled copy function, could that help speeding up an element-wise copy? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @gfwilliams As I'd said above, Chrome is spec compliant. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array The constructor is:
In this case, you're not passing in |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @allObjects NICE! --- me: ddddoooohhhh (: ... LOL... That's where implicit - wishful - typing by variable naming (trap) kicks in... the 'wrong' name has been chosen for the variable: buffer is not a buffer because it is called so... ;( I made a rough performance test, and it shows that slice is still about 6 times slower (even with some optimization / moving the
PS: updated - (line 18 had buf.buf and passing undefined which did speed it up to factor 2) Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-23 by @allObjects Espruino test (uploaded from editor pane and invoked with
Console:
Interesting is the relatively great variation... so I run it with
Have no answer why... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-24 by @gfwilliams So you're saying that it gets worse the larger the offset in the ArrayBuffer? I think it's due to the implementation of Because of that it's just iterating to get to the correct start index - even though with an ArrayBuffer it could just go straight there in most cases. I've just filed an issue for this. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-24 by @MaBecker wow - thanks to both for your effort and those very interesting explanations and samples ! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-24 by @MaBecker So let me share the motivation behind this. All npm modules out there are using Oled data updates byte by byte - so you can imagine how slow the screen updates are - takes more than 1sec for a full screen update. The Espruino SSD1306.js does it different, updates are so quick - because it uses chunks to update. So I decided to pimp the npm module I use for my beaglebone projects. And this is the result: MaBecker/oled-i2c-bus@c099f61 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-11-24 by @gfwilliams Neat - thanks for the comment in the commit! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-11-23 by @MaBecker
this works excellent for Espruino
but anywhere else it causes something like "RangeError: Offset/length out of range" for chunk.
Any suggestions how to rewrite this line
to work with other javascript engines ?
Beta Was this translation helpful? Give feedback.
All reactions