It is best to measure such things, intuition is often wrong, at least mine is ;) Also worth testing in multiple browsers.
If you need to copy over 5,000 floats, you can just read and write from the singleton big typed array, HEAPU8 for example. - Alon On Sun, Apr 13, 2014 at 9:52 PM, Joshua Litt <[email protected]> wrote: > Okay thanks, that helps. > > At what length function should I favor using plain JS vs emscripten? I > have some simple calls, such as a vector multiply. My intuition is its > cheaper to just multiply two small vectors in JS than it is to call into > emscripten. Is this correct? > > Also, how expensive are callbacks? I have a situation where I need access > to an array of around 5000 floats. Right now I copy the whole array back > into the native layer when I need it. I could also just issue a callback > for each data item, but that seems more expensive. It'd be nice to be able > to just read the doubles in place, but something tells me that is not > possible. > > > On Sunday, April 13, 2014 7:11:17 PM UTC-7, Alon Zakai wrote: > >> Avoiding creating an array object is usually faster. But it might not >> matter much. >> >> What might make a bigger difference is if you have 16 plain numeric >> arguments, you can use ccall or even call it directly, with almost no >> overhead, whereas with embind or ccall using an array it would have more >> work to do. >> >> - Alon >> >> >> >> On Fri, Apr 11, 2014 at 10:47 AM, Joshua Litt <[email protected]>wrote: >> >>> I have a c function which takes an array. This array can have no more >>> than 16 values. Is it better from a performance standpoint to allocate an >>> array in JS, and pass it to emscripten, or should I just unpack the array >>> into 16 values and make a function which takes that many arguments? >>> >>> If it matters, most of the time the array will probably be half full. >>> >>> -- >>> 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. > -- 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.
