Hi all, I have been following along in the "Ray Tracing in a Weekend" book and trying to make as many classes as possible value classes. (Vec3, Ray, etc.)
https://github.com/bowbahdoe/raytracer https://raytracing.github.io/books/RayTracingInOneWeekend.html (without value classes) time java --enable-preview --class-path build/classes Main > image.ppm real 4m33.190s user 4m28.984s sys 0m5.511s (with value classes) time java --enable-preview --class-path build/classes Main > image.ppm real 3m54.623s user 3m52.205s sys 0m2.064s So by the end the version using value classes beats the version without them by ~14% using unscientific measurements. But that is at the end, running the ray tracer on a relatively large scene with all the features turned on. Before that point there were some checkpoints where using value classes performed noticeably worse than the equivalent code sans the value modifier https://github.com/bowbahdoe/raytracer/tree/no-value-faster real 1m22.172s user 1m9.871s sys 0m12.951s https://github.com/bowbahdoe/raytracer/tree/with-value-slower real 3m34.440s user 3m19.656s sys 0m14.870s So for some reason just adding value to the records/classes makes the program run a over 2x as slow. https://github.com/bowbahdoe/raytracer/compare/no-value-faster...with-value-slower Is there some intuition that explains this? I am on a stock M1 Arm Mac.
