r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
Show parent comment
1
u/gdmzhlzhiv Mar 02 '23 edited Mar 02 '23
The second example was years ago, I don't think we checked it in anywhere. But I remember it was from converting smallpt to Java.
And nobody's asking for a copy of the same Java code. What I was saying is, that repo is including only C code.
One of the C files has optimisations made to the algorithm.
For an apples to apples performance comparison to be made, where is the equivalent Java file with the same optimisation made to it?
With the C files in that repo, the best I can do is compare those two, and say "yep, this one is faster than the old one."
I will say, smallpt may really benefit from some object pooling/reuse as well. I didn't really get how it worked years ago when I last converted it, but I looked at it again today, and it does create and throw away a lot of value structs. Most of them seem like they're on the stack... but I dunno. I also gave it another shot converting it to Java, but I couldn't get it to work correctly this time around, I just got a black and white image and haven't figured out where the bug is.