Re:ClojureScript and optimized C [video]
by mpweiher on Monday November 28, 2016 @02:03PM
(#13057572)
I think the problem is that it's using doubles, which JavaScript VMs feel free to optimise to ints. If I change the C code to long, I get the following:
Re:ClojureScript and optimized C [video]
by jjnoakes on Monday November 28, 2016 @02:35PM
(#13057773)
Can you post your code, compiler, and the disassembly from main()? The only way I believe these numbers is if your compiler optimized the loop away to a constant.
Re:ClojureScript and optimized C [video]
by mwkaufma on Monday November 28, 2016 @02:33PM
(#13057769)
Correct me if I'm wrong, but this is basically just timing how fast we can read and write to a single CPU register, so it's eliding all the memory bottlenecks that actually surface performance differences between native hotloops and JITed code.
Re:ClojureScript and optimized C [video]
by bad_user on Monday November 28, 2016 @05:23PM
(#13058945)
I'm working on a cross-compiled library and I am able to compare the same code compiled for the JVM and for Javascript, the language used being Scala, which targets the JVM as a primary target and now we also have http://scala-js.org which is quite good btw.
I can tell you that the answer is definitely no, in my tests V8 being slower than the JVM by a factor ranging between 4 and 10.
If you're interested in seeing that in action, you can download the library's source code and run its tests for the JVM and see how that feels in comparison with the same tests being executed for JS. See: https://github.com/monix/monix
Re:ClojureScript and optimized C [video]
by verandaguy on Monday November 28, 2016 @02:15PM
(#13057642)
Probably just the parser getting tired.
In seriousness -- does this behaviour persist if you drop the computation into a `for` loop for a number of iterations instead of calling it manually every time?
The code in question:
is just summing a bunch of numbers. That's it. It's very easy to optimize for the sake of benchmarks.It's way too trivial to use for any kind of meaningful real-world comparison.
I can tell you that the answer is definitely no, in my tests V8 being slower than the JVM by a factor ranging between 4 and 10.
If you're interested in seeing that in action, you can download the library's source code and run its tests for the JVM and see how that feels in comparison with the same tests being executed for JS. See: https://github.com/monix/monix
[PS: Next time remember to submit the youtube.com version instead of the youtu.be, because youtu.be is autokilled.]
https://gist.github.com/sfermigier/9f60f01d1b4e8508a3a56bc42...
Any idea why ?
In seriousness -- does this behaviour persist if you drop the computation into a `for` loop for a number of iterations instead of calling it manually every time?