<div dir="ltr">Hi all,<br><br>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.)<br><br><a href="https://github.com/bowbahdoe/raytracer">https://github.com/bowbahdoe/raytracer</a><br><br><a href="https://raytracing.github.io/books/RayTracingInOneWeekend.html">https://raytracing.github.io/books/RayTracingInOneWeekend.html</a><br><br><font face="monospace">(without value classes)</font><br><br><font face="monospace">time java --enable-preview --class-path build/classes Main > image.ppm                 </font><br><br><font face="monospace">real      4m33.190s</font><br><font face="monospace">user     4m28.984s</font><br><font face="monospace">sys      0m5.511s</font><br><br><font face="monospace">(with value classes)</font><br><br><font face="monospace">time java --enable-preview --class-path build/classes Main > image.ppm               </font><br><br><font face="monospace">real       3m54.623s</font><br><font face="monospace">user     3m52.205s</font><br><font face="monospace">sys      0m2.064s</font><br><br><font face="arial, sans-serif">So by the end the version using value classes beats the version without them by ~14% using unscientific measurements.<br><br>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<br><br></font><a href="https://github.com/bowbahdoe/raytracer/tree/no-value-faster">https://github.com/bowbahdoe/raytracer/tree/no-value-faster</a><br><br><font face="monospace">real    1m22.172s<br>user 1m9.871s<br>sys   0m12.951s</font><br><br><a href="https://github.com/bowbahdoe/raytracer/tree/with-value-slower">https://github.com/bowbahdoe/raytracer/tree/with-value-slower</a>         <br><br><font face="monospace">real  3m34.440s<br>user 3m19.656s<br>sys  0m14.870s</font><br><br><font face="arial, sans-serif">So for some reason just adding </font><font face="monospace">value</font><font face="arial, sans-serif"> to the records/classes makes the program run a over 2x as slow.<br><br></font><a href="https://github.com/bowbahdoe/raytracer/compare/no-value-faster...with-value-slower">https://github.com/bowbahdoe/raytracer/compare/no-value-faster...with-value-slower</a><br><br>Is there some intuition that explains this? I am on a stock M1 Arm Mac.<font face="arial, sans-serif"></font></div>