From b10888e575d757d23cace28c8e12b8ea4ec5c2d0 Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Tue, 21 Mar 2023 23:11:32 +0100 Subject: =?UTF-8?q?=F0=9F=99=83=20Tried=20this,=20was=20not=20worth=20the?= =?UTF-8?q?=20performance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Did a test where I removed all the operators for vec and forced the user to use functions on the vector instead that mutated the existing vector. You had to manually call clone if you actually wanted a new vector. No automatic copies were done. Expected the performace to increase by quite a bit since most of the operations are vector operations. Chaining operations like the following just mutated the existing vector. ``` vec.mul(vec2).div(2).add(vec3); ``` Could do this pattern for most things. Turns out is's not such a big deal. Set up a test case of the simple scene with 3 balls. The difference in performance was about 1%. Got surprised and made a more complex scene with over 400 objects expecting to get a bigger difference. Nope. Still 1%. Decided it was not worth it since it was a bit more annoying working with the vectors. Probably get better performance gains with SIMD or using the GPU. --- racer-tracer/src/vec3.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/racer-tracer/src/vec3.rs b/racer-tracer/src/vec3.rs index 281fb26..9d04cb4 100644 --- a/racer-tracer/src/vec3.rs +++ b/racer-tracer/src/vec3.rs @@ -4,7 +4,6 @@ use serde::Deserialize; use crate::util::{random_double, random_double_range}; -// TODO: Remove clone and copy. We want to be aware when this happens to save time. #[derive(Default, Clone, Copy, Deserialize)] pub struct Vec3 { data: [f64; 3], -- cgit v1.2.3