EM_ASM is not exactly inline assembly. It looks like it, but we must call out into a function that contains the code. So there is function call overhead.
We used to support inline code directly, but the problem is you must write perfect code that validates as asm.js, which is hard to do by hand, especially when you are writing inside another function and not writing the entire function by yourself. What you can easily do though is use a js library to implement an entire function in asm.js by hand, see src/library.js for example (grep for __asm). - Alon On Fri, Apr 4, 2014 at 11:11 AM, physicsrob <[email protected]> wrote: > Hello, > > I'm trying to optimize a tight loop. I was hoping to use inline > javascript for some of the contents of this loop, but it looks like the > performance costs far out-weight the benefits (by several orders of > magnitude). In short -- EM_ASM appears to be really really slow. Here's > the code to reproduce: > > float start = emscripten_get_now(); > for(int i=0;i<10000;i++) { EM_ASM({}); } > printf("Total Time: %f ms\n", emscripten_get_now() - start); > > > This code is taking about 600ms on firefox, and about 2 seconds on chrome. > To me this is shockingly slow. Does this performance make sense? Should > I file a bug report? > > On a related note: I would really like to directly inline asm.js with no > unnecessary overhead. Is there any way to do that? > > Thanks in advance for any help or suggestions. > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
