MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/bsuurg/making_the_obvious_code_fast/eoribcm/?context=3
r/programming • u/[deleted] • May 25 '19
263 comments sorted by
View all comments
35
Great post! I'm surprised to see that the Java code wasn't as fast as C#. Minor nit: Using floating point values means that SIMD results are not the same as the non-SIMD results.
3 u/LPTK May 25 '19 the Java code wasn't as fast as C#Huh? I don't understand what you are talking about.The blog only showed the streaming API for Java, and the equivalent C# LINQ code was more than 7x slower (260ms against 34ms).In fact, Java's stream API using higher-order functions was exactly as fast as the low-level C# loop. 11 u/theindigamer May 25 '19 The fastest C# code is faster than the fastest Java code because of SIMD. 2 u/LPTK May 26 '19 I'm surprised to see that the Java code wasn't as fast as C#So did you mean to say that you were surprised the JVM's JIT didn't produce SIMD instructions automatically?Did you not address the reason yourself, with your remark that:SIMD results are not the same as the non-SIMD results? → More replies (2)
3
the Java code wasn't as fast as C#
Huh? I don't understand what you are talking about.
The blog only showed the streaming API for Java, and the equivalent C# LINQ code was more than 7x slower (260ms against 34ms).
In fact, Java's stream API using higher-order functions was exactly as fast as the low-level C# loop.
11 u/theindigamer May 25 '19 The fastest C# code is faster than the fastest Java code because of SIMD. 2 u/LPTK May 26 '19 I'm surprised to see that the Java code wasn't as fast as C#So did you mean to say that you were surprised the JVM's JIT didn't produce SIMD instructions automatically?Did you not address the reason yourself, with your remark that:SIMD results are not the same as the non-SIMD results? → More replies (2)
11
The fastest C# code is faster than the fastest Java code because of SIMD.
2 u/LPTK May 26 '19 I'm surprised to see that the Java code wasn't as fast as C#So did you mean to say that you were surprised the JVM's JIT didn't produce SIMD instructions automatically?Did you not address the reason yourself, with your remark that:SIMD results are not the same as the non-SIMD results? → More replies (2)
2
I'm surprised to see that the Java code wasn't as fast as C#
So did you mean to say that you were surprised the JVM's JIT didn't produce SIMD instructions automatically?
Did you not address the reason yourself, with your remark that:
SIMD results are not the same as the non-SIMD results
?
35
u/theindigamer May 25 '19
Great post! I'm surprised to see that the Java code wasn't as fast as C#. Minor nit: Using floating point values means that SIMD results are not the same as the non-SIMD results.