Quote:
Original post by Antheus
Quote:
Original post by nullsquared
In fact, notice how most of the measurements for the C version were 0s. The last one in C was either a fluke, or their Java measurements were inaccurate.
So you reject the reality and substitute your own? Your statement means that both Java and C version fluked on same test, and they were both pair-wise correct on every other test.
Wait what? No, I'm just saying their timing doesn't look too correct.
Quote:
Since this is a trivial case, depending on how C code gets compiled, the Java version might put variables closer together, reducing number of cache misses. Just one or two cases as such and you've saved several hundred, perhaps even thousands of cycles.
Of course. And I seriously doubt the JVM JIT compilation out-smarted the C compiler, especially with cache-friendly memory. Java's arrays are Object's and have lots of crap associated with them. The C code was about as cache friendly as it can get. (maybe cache_hit can point something out here [wink])
Quote:
Code hasn't been a bottleneck in a while now, memory is. And while it cannot be controlled, unless specifically managed in C, JVM might just result in slightly more optimal version, considering we're dealing with arrays, which Java can allocate in place, compared to List<> which requires instances of objects.
Wait what? Lists have nothing to do with this, I don't see your point of bringing them in. Java does have the advantage of a GC memory system, however that can also be a disadvantage. The C version is performing continuous access on raw memory. The Java version is performing access on an Object which happens to be an array, and who knows what else is going on behind the scene.
Quote:
So C or C++ application can never be faster than something written in assembly?
Nope, as long as the assembly is written perfectly. The problem here is that compilers will usually write better assembly than a human being, so your argument is a bit of a moot point.
Quote:
BTW, do not underestimate JVM's design. When it comes to large application (1MLOC+), JVM will offer considerably better run-time characteristics than equivalent-effort C++ application precisely due to memory management. I mean this seriously, the micro overhead starts mattering surprisingly little above certain size, without even mentioning the difference in development time.
For GUI based tools and what-not, perhaps you're right. But if Java wasn't so dog-slow, then maybe Crysis can be optimized a bit if it was rewritten in Java [lol]