3 ms·
Yesterday I rewrote a tiny Javascript demo in asm.js and also saw an order-of-magnitude speedup. (I thought at first it didn't help at all, apparently because t
by abecedarius 14y ago
Yesterday I rewrote a tiny Javascript demo in asm.js and also saw an order-of-magnitude speedup. (I thought at first it didn't help at all, apparently because the framerate was limited by setInterval().)
Code at http://wry.me/hacking/canvas_asm.html http://wry.me/hacking/canvas_asm.html
- simcop2387 14y agoDoesn't appear to be doing anything for me, noasm 285 asm 13 asm 13 noasm 269 That's all that appears in the console. Network and everything looks fine, no 404 or other errors.
- abecedarius 14y agoYes, I disabled display so that wouldn't get into the benchmark. The numbers are times in milliseconds.
- Groxx 14y agoI wonder if most / all of that speedup is just using typed arrays (edit: nvm, they both do). I get similar speeds in Chrome, which afaik doesn't have any special handling for `"use asm";` functions.
- srijs 14y agoTyped arrays do deliver a lot of speedup, and in fact, the above example is slightly faster in Chrome than in Firefox Nightly for me. However, if your algorithm does crunch a lot of data in a low-level way, there is definitely even more performance you can get by using asm.js. See my link in the comment below for benchmarks of a sha1 algorithm that shows a good speedup in Chrome by using TypedArrays, but an even greater one in OdinMonkey.
- Groxx 14y agoawesome - thanks for doing the legwork! I'll definitely take a look.
- srijs 14y agoCool. I recently wrote a low-level sha1 implementation in pure javascript, trying to leverage asm.js (http://github.com/srijs/rusha http://github.com/srijs/rusha). Can you tell me, how did you confirm you wrote valid asm.js and there was no fallback-mechanism kicking in? I benchmarked my implementation, of course, and noticed a 2x speedup. However, this seems quite less for the this type of low-level algorithm...
- abecedarius 14y agoOpen the error console (via the Web Developer menu item) and you'll see messages there. Success shows up as "Error: successfully compiled asm.js code." :-) P.S. Looking at your code, I can tell it's not asm.js conformant yet, though it should just be a bunch of small tweaks (e.g. an expression like (a+b) will need to be (a+b)|0, etc.).
- srijs 14y agoThank you. I just updated my code and it's really within half of native speed now... (benchmarks in the README, if any of you are interested) asm.js is very exciting technology!
- abecedarius 14y agoYou're welcome!
- gruseom 14y agoThat is the most exciting news I've heard in quite a while.