From 3685386001194bf051dd0fd1c63dbe726c3ae8c9 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sun, 26 Jul 2026 13:50:40 +1200 Subject: [PATCH 1/2] Updated dependencies. Benchmarks and README not updated. --- Cargo.toml | 16 +-- src/lib.rs | 400 ++++++++++++++++++++++++++--------------------------- 2 files changed, 208 insertions(+), 208 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ced67c2..751c606 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,22 +33,22 @@ unstable = [] [dependencies] mint = "0.5.9" -rand = "0.8.5" -rand_pcg = "0.3.1" +rand = "0.10.2" +rand_pcg = "0.10.2" [dependencies.glam] -version = "0.29.0" +version = "0.33.2" features = ["mint", "rand"] # a lot of random data generation uses glam, so can't be optional yet # optional = true [dependencies.nalgebra] -version = "0.33.2" +version = "0.35.0" features = ["mint"] optional = true [dependencies.simba] -version = "0.9.0" +version = "0.10.0" optional = true [dependencies.cgmath] @@ -74,17 +74,17 @@ version = "0.2.3" optional = true [dependencies.ultraviolet] -version = "0.9.0" +version = "0.10.0" features = ["mint"] optional = true [dependencies.wide_mathbench] package = "wide" -version = "0.7.5" +version = "1.5.0" optional = true [dev-dependencies] -criterion = "0.5.1" +criterion = "0.8.2" # [patch.crates-io] # glam = { path = "../glam-rs" } diff --git a/src/lib.rs b/src/lib.rs index ba45167..d3c4d2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ -use rand::Rng; +use rand::RngExt; pub trait BenchValue { - fn random_value(rng: &mut R) -> Self; + fn random_value(rng: &mut R) -> Self; // Return self to test overhead of benches fn ret_self(&self) -> Self where @@ -12,15 +12,15 @@ pub trait BenchValue { } impl BenchValue for f32 { - fn random_value(rng: &mut R) -> Self { - rng.gen() + fn random_value(rng: &mut R) -> Self { + rng.random() } } macro_rules! impl_bench_value { ($t:ty, $f:expr) => { impl BenchValue for $t { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { $f(rng).into() } } @@ -29,64 +29,64 @@ macro_rules! impl_bench_value { pub mod mint_support { use super::glam_support::*; - use rand::Rng; + use rand::RngExt; // mint random functions ----------------------------------------------------- pub fn random_mint_quat(rng: &mut R) -> mint::Quaternion where - R: Rng, + R: RngExt, { random_glam_quat(rng).into() } pub fn random_mint_vec2(rng: &mut R) -> mint::Vector2 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 2]>().into() + rng.random::<[f32; 2]>().into() } pub fn random_mint_vec3(rng: &mut R) -> mint::Vector3 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 3]>().into() + rng.random::<[f32; 3]>().into() } pub fn random_mint_vec4(rng: &mut R) -> mint::Vector4 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 4]>().into() + rng.random::<[f32; 4]>().into() } pub fn random_mint_mat2(rng: &mut R) -> mint::ColumnMatrix2 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 4]>().into() + rng.random::<[f32; 4]>().into() } pub fn random_mint_mat3(rng: &mut R) -> mint::ColumnMatrix3 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 9]>().into() + rng.random::<[f32; 9]>().into() } pub fn random_mint_mat4(rng: &mut R) -> mint::ColumnMatrix4 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 16]>().into() + rng.random::<[f32; 16]>().into() } pub fn random_mint_invertible_mat2(rng: &mut R) -> mint::ColumnMatrix2 where - R: Rng, + R: RngExt, { loop { - let m = glam::Mat2::from_cols_array(&rng.gen::<[f32; 4]>()); + let m = glam::Mat2::from_cols_array(&rng.random::<[f32; 4]>()); if m.determinant().abs() > std::f32::EPSILON { return m.into(); } @@ -95,7 +95,7 @@ pub mod mint_support { pub fn random_mint_homogeneous_mat3(rng: &mut R) -> mint::ColumnMatrix3 where - R: Rng, + R: RngExt, { loop { let m = glam::Mat3::from_scale_angle_translation( @@ -111,7 +111,7 @@ pub mod mint_support { pub fn random_mint_homogeneous_mat4(rng: &mut R) -> mint::ColumnMatrix4 where - R: Rng, + R: RngExt, { loop { let m = glam::Mat4::from_scale_rotation_translation( @@ -129,7 +129,7 @@ pub mod mint_support { pub mod glam_support { use super::mint_support::*; use super::BenchValue; - use rand::Rng; + use rand::RngExt; impl_bench_value!(glam::Mat2, random_mint_invertible_mat2); impl_bench_value!(glam::Mat3, random_mint_homogeneous_mat3); impl_bench_value!(glam::Mat4, random_mint_homogeneous_mat4); @@ -144,43 +144,43 @@ pub mod glam_support { // f32 random functions ------------------------------------------------------ fn random_nonzero_f32(rng: &mut R) -> f32 where - R: Rng, + R: RngExt, { - rng.gen_range(0.1..1.0) + rng.random_range(0.1..1.0) } pub fn random_angle_radians(rng: &mut R) -> f32 where - R: Rng, + R: RngExt, { - rng.gen_range(-std::f32::consts::PI..std::f32::consts::PI) + rng.random_range(-std::f32::consts::PI..std::f32::consts::PI) } // glam random functions ------------------------------------------------------ pub fn random_glam_vec2(rng: &mut R) -> glam::Vec2 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 2]>().into() + rng.random::<[f32; 2]>().into() } pub fn random_glam_vec3(rng: &mut R) -> glam::Vec3 where - R: Rng, + R: RngExt, { - rng.gen::<[f32; 3]>().into() + rng.random::<[f32; 3]>().into() } pub fn random_nonzero_glam_vec2(rng: &mut R) -> glam::Vec2 where - R: Rng, + R: RngExt, { glam::Vec2::new(random_nonzero_f32(rng), random_nonzero_f32(rng)) } pub fn random_glam_nonzero_vec3(rng: &mut R) -> glam::Vec3 where - R: Rng, + R: RngExt, { glam::Vec3::new( random_nonzero_f32(rng), @@ -191,7 +191,7 @@ pub mod glam_support { pub fn random_glam_quat(rng: &mut R) -> glam::Quat where - R: Rng, + R: RngExt, { let yaw = random_angle_radians(rng); let pitch = random_angle_radians(rng); @@ -201,7 +201,7 @@ pub mod glam_support { pub fn random_glam_affine2(rng: &mut R) -> glam::Affine2 where - R: Rng, + R: RngExt, { glam::Affine2::from_scale_angle_translation( random_nonzero_glam_vec2(rng), @@ -212,7 +212,7 @@ pub mod glam_support { pub fn random_glam_affine3a(rng: &mut R) -> glam::Affine3A where - R: Rng, + R: RngExt, { glam::Affine3A::from_scale_rotation_translation( random_glam_nonzero_vec3(rng), @@ -248,7 +248,7 @@ pub mod glam_support { pub mod cgmath_support { use super::mint_support::*; use super::BenchValue; - use rand::Rng; + use rand::RngExt; impl_bench_value!( cgmath::Decomposed, cgmath::Quaternion>, random_cgmath_decomposed3 @@ -268,10 +268,10 @@ pub mod cgmath_support { rng: &mut R, ) -> cgmath::Decomposed, cgmath::Quaternion> where - R: Rng, + R: RngExt, { cgmath::Decomposed { - scale: rng.gen_range(0.1..1.0), + scale: rng.random_range(0.1..1.0), rot: random_mint_quat(rng).into(), disp: random_mint_vec3(rng).into(), } @@ -279,7 +279,7 @@ pub mod cgmath_support { fn random_cgmath_point2(rng: &mut R) -> cgmath::Point2 where - R: Rng, + R: RngExt, { let v = random_mint_vec2(rng); cgmath::Point2::new(v.x, v.y) @@ -287,7 +287,7 @@ pub mod cgmath_support { fn random_cgmath_point3(rng: &mut R) -> cgmath::Point3 where - R: Rng, + R: RngExt, { let v = random_mint_vec3(rng); cgmath::Point3::new(v.x, v.y, v.z) @@ -321,7 +321,7 @@ pub mod cgmath_support { pub mod nalgebra_support { use super::mint_support::*; use super::BenchValue; - use rand::Rng; + use rand::RngExt; impl_bench_value!(nalgebra::Matrix2, random_mint_invertible_mat2); impl_bench_value!(nalgebra::Matrix3, random_mint_homogeneous_mat3); impl_bench_value!(nalgebra::Matrix4, random_mint_homogeneous_mat4); @@ -339,57 +339,57 @@ pub mod nalgebra_support { impl_bench_value!(nalgebra::Vector3, random_na_dvec3); // nalgebra random functions -------------------------------------------------- - fn random_na_cplx(rng: &mut R) -> nalgebra::UnitComplex { + fn random_na_cplx(rng: &mut R) -> nalgebra::UnitComplex { let angle = crate::glam_support::random_angle_radians(rng); nalgebra::UnitComplex::new(angle) } - fn random_na_quat(rng: &mut R) -> nalgebra::UnitQuaternion { + fn random_na_quat(rng: &mut R) -> nalgebra::UnitQuaternion { nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()) } - fn random_na_iso2(rng: &mut R) -> nalgebra::Isometry2 { + fn random_na_iso2(rng: &mut R) -> nalgebra::Isometry2 { let rot = nalgebra::UnitComplex::random_value(rng); let tra = nalgebra::Vector2::random_value(rng); nalgebra::Isometry2::from_parts(tra.into(), rot) } - fn random_na_iso3(rng: &mut R) -> nalgebra::Isometry3 { + fn random_na_iso3(rng: &mut R) -> nalgebra::Isometry3 { let rot = nalgebra::UnitQuaternion::random_value(rng); let tra = nalgebra::Vector3::random_value(rng); nalgebra::Isometry3::from_parts(tra.into(), rot) } - fn random_na_transform2(rng: &mut R) -> nalgebra::Transform2 { + fn random_na_transform2(rng: &mut R) -> nalgebra::Transform2 { nalgebra::Transform2::from_matrix_unchecked(random_mint_homogeneous_mat3(rng).into()) } - fn random_na_transform3(rng: &mut R) -> nalgebra::Transform3 { + fn random_na_transform3(rng: &mut R) -> nalgebra::Transform3 { nalgebra::Transform3::from_matrix_unchecked(random_mint_homogeneous_mat4(rng).into()) } - fn random_na_point2(rng: &mut R) -> nalgebra::Point2 { - rng.gen::<[f32; 2]>().into() + fn random_na_point2(rng: &mut R) -> nalgebra::Point2 { + rng.random::<[f32; 2]>().into() } - fn random_na_point3(rng: &mut R) -> nalgebra::Point3 { - rng.gen::<[f32; 3]>().into() + fn random_na_point3(rng: &mut R) -> nalgebra::Point3 { + rng.random::<[f32; 3]>().into() } - fn random_na_vec2(rng: &mut R) -> nalgebra::Vector2 { - rng.gen::<[f32; 2]>().into() + fn random_na_vec2(rng: &mut R) -> nalgebra::Vector2 { + rng.random::<[f32; 2]>().into() } - fn random_na_vec3(rng: &mut R) -> nalgebra::Vector3 { - rng.gen::<[f32; 3]>().into() + fn random_na_vec3(rng: &mut R) -> nalgebra::Vector3 { + rng.random::<[f32; 3]>().into() } - fn random_na_vec4(rng: &mut R) -> nalgebra::Vector4 { - rng.gen::<[f32; 4]>().into() + fn random_na_vec4(rng: &mut R) -> nalgebra::Vector4 { + rng.random::<[f32; 4]>().into() } - fn random_na_dvec3(rng: &mut R) -> nalgebra::Vector3 { - rng.gen::<[f64; 3]>().into() + fn random_na_dvec3(rng: &mut R) -> nalgebra::Vector3 { + rng.random::<[f64; 3]>().into() } pub fn nalgebra_mat4_det(m: &nalgebra::Matrix4) -> f32 { @@ -416,7 +416,7 @@ pub mod nalgebra_support { pub mod nalgebra_support_wide { use super::mint_support::*; use super::BenchValue; - use rand::Rng; + use rand::RngExt; use simba::simd::{f32x16, f32x4, f32x8, f64x2, f64x4, f64x8}; impl_bench_value!(nalgebra::Point2, random_na_point2x4); impl_bench_value!(nalgebra::Point3, random_na_point3x4); @@ -462,7 +462,7 @@ pub mod nalgebra_support_wide { impl_bench_value!(nalgebra::Isometry3, random_na_iso3x16); // nalgebra random functions -------------------------------------------------- - fn random_na_cplx4(rng: &mut R) -> nalgebra::UnitComplex { + fn random_na_cplx4(rng: &mut R) -> nalgebra::UnitComplex { [ nalgebra::UnitComplex::new(crate::glam_support::random_angle_radians(rng)), nalgebra::UnitComplex::new(crate::glam_support::random_angle_radians(rng)), @@ -472,7 +472,7 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_cplx8(rng: &mut R) -> nalgebra::UnitComplex { + fn random_na_cplx8(rng: &mut R) -> nalgebra::UnitComplex { [ nalgebra::UnitComplex::new(crate::glam_support::random_angle_radians(rng)), nalgebra::UnitComplex::new(crate::glam_support::random_angle_radians(rng)), @@ -486,7 +486,7 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_cplx16(rng: &mut R) -> nalgebra::UnitComplex { + fn random_na_cplx16(rng: &mut R) -> nalgebra::UnitComplex { [ nalgebra::UnitComplex::new(crate::glam_support::random_angle_radians(rng)), nalgebra::UnitComplex::new(crate::glam_support::random_angle_radians(rng)), @@ -508,7 +508,7 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_quat4(rng: &mut R) -> nalgebra::UnitQuaternion { + fn random_na_quat4(rng: &mut R) -> nalgebra::UnitQuaternion { [ nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()), nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()), @@ -518,7 +518,7 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_quat8(rng: &mut R) -> nalgebra::UnitQuaternion { + fn random_na_quat8(rng: &mut R) -> nalgebra::UnitQuaternion { [ nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()), nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()), @@ -532,7 +532,7 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_quat16(rng: &mut R) -> nalgebra::UnitQuaternion { + fn random_na_quat16(rng: &mut R) -> nalgebra::UnitQuaternion { [ nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()), nalgebra::UnitQuaternion::from_quaternion(random_mint_quat(rng).into()), @@ -554,13 +554,13 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_iso2x4(rng: &mut R) -> nalgebra::Isometry2 { + fn random_na_iso2x4(rng: &mut R) -> nalgebra::Isometry2 { let rot = nalgebra::UnitComplex::random_value(rng); let tra = nalgebra::Vector2::random_value(rng); nalgebra::Isometry2::from_parts(tra.into(), rot) } - fn random_na_iso2x8(rng: &mut R) -> nalgebra::Isometry2 { + fn random_na_iso2x8(rng: &mut R) -> nalgebra::Isometry2 { let rot = nalgebra::UnitComplex::random_value(rng); let tra = nalgebra::Vector2::random_value(rng); nalgebra::Isometry2::from_parts(tra.into(), rot) @@ -568,64 +568,64 @@ pub mod nalgebra_support_wide { fn random_na_iso2x16(rng: &mut R) -> nalgebra::Isometry2 where - R: Rng, + R: RngExt, { let rot = nalgebra::UnitComplex::random_value(rng); let tra = nalgebra::Vector2::random_value(rng); nalgebra::Isometry2::from_parts(tra.into(), rot) } - fn random_na_iso3x4(rng: &mut R) -> nalgebra::Isometry3 { + fn random_na_iso3x4(rng: &mut R) -> nalgebra::Isometry3 { let rot = nalgebra::UnitQuaternion::random_value(rng); let tra = nalgebra::Vector3::random_value(rng); nalgebra::Isometry3::from_parts(tra.into(), rot) } - fn random_na_iso3x8(rng: &mut R) -> nalgebra::Isometry3 { + fn random_na_iso3x8(rng: &mut R) -> nalgebra::Isometry3 { let rot = nalgebra::UnitQuaternion::random_value(rng); let tra = nalgebra::Vector3::random_value(rng); nalgebra::Isometry3::from_parts(tra.into(), rot) } - fn random_na_iso3x16(rng: &mut R) -> nalgebra::Isometry3 { + fn random_na_iso3x16(rng: &mut R) -> nalgebra::Isometry3 { let rot = nalgebra::UnitQuaternion::random_value(rng); let tra = nalgebra::Vector3::random_value(rng); nalgebra::Isometry3::from_parts(tra.into(), rot) } - fn random_na_point2x4(rng: &mut R) -> nalgebra::Point2 { + fn random_na_point2x4(rng: &mut R) -> nalgebra::Point2 { random_na_vec2x4(rng).into() } - fn random_na_point3x4(rng: &mut R) -> nalgebra::Point3 { + fn random_na_point3x4(rng: &mut R) -> nalgebra::Point3 { random_na_vec3x4(rng).into() } - fn random_na_point2x8(rng: &mut R) -> nalgebra::Point2 { + fn random_na_point2x8(rng: &mut R) -> nalgebra::Point2 { random_na_vec2x8(rng).into() } - fn random_na_point3x8(rng: &mut R) -> nalgebra::Point3 { + fn random_na_point3x8(rng: &mut R) -> nalgebra::Point3 { random_na_vec3x8(rng).into() } - fn random_na_point2x16(rng: &mut R) -> nalgebra::Point2 { + fn random_na_point2x16(rng: &mut R) -> nalgebra::Point2 { random_na_vec2x16(rng).into() } - fn random_na_point3x16(rng: &mut R) -> nalgebra::Point3 { + fn random_na_point3x16(rng: &mut R) -> nalgebra::Point3 { random_na_vec3x16(rng).into() } - fn random_na_vec2x4(rng: &mut R) -> nalgebra::Vector2 { + fn random_na_vec2x4(rng: &mut R) -> nalgebra::Vector2 { [random_f32x4(rng), random_f32x4(rng)].into() } - fn random_na_vec3x4(rng: &mut R) -> nalgebra::Vector3 { + fn random_na_vec3x4(rng: &mut R) -> nalgebra::Vector3 { [random_f32x4(rng), random_f32x4(rng), random_f32x4(rng)].into() } - fn random_na_vec4x4(rng: &mut R) -> nalgebra::Vector4 { + fn random_na_vec4x4(rng: &mut R) -> nalgebra::Vector4 { [ random_f32x4(rng), random_f32x4(rng), @@ -635,15 +635,15 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_vec2x8(rng: &mut R) -> nalgebra::Vector2 { + fn random_na_vec2x8(rng: &mut R) -> nalgebra::Vector2 { [random_f32x8(rng), random_f32x8(rng)].into() } - fn random_na_vec3x8(rng: &mut R) -> nalgebra::Vector3 { + fn random_na_vec3x8(rng: &mut R) -> nalgebra::Vector3 { [random_f32x8(rng), random_f32x8(rng), random_f32x8(rng)].into() } - fn random_na_vec4x8(rng: &mut R) -> nalgebra::Vector4 { + fn random_na_vec4x8(rng: &mut R) -> nalgebra::Vector4 { [ random_f32x8(rng), random_f32x8(rng), @@ -653,15 +653,15 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_vec2x16(rng: &mut R) -> nalgebra::Vector2 { + fn random_na_vec2x16(rng: &mut R) -> nalgebra::Vector2 { [random_f32x16(rng), random_f32x16(rng)].into() } - fn random_na_vec3x16(rng: &mut R) -> nalgebra::Vector3 { + fn random_na_vec3x16(rng: &mut R) -> nalgebra::Vector3 { [random_f32x16(rng), random_f32x16(rng), random_f32x16(rng)].into() } - fn random_na_vec4x16(rng: &mut R) -> nalgebra::Vector4 { + fn random_na_vec4x16(rng: &mut R) -> nalgebra::Vector4 { [ random_f32x16(rng), random_f32x16(rng), @@ -671,95 +671,95 @@ pub mod nalgebra_support_wide { .into() } - fn random_na_dvec2x2(rng: &mut R) -> nalgebra::Vector2 { + fn random_na_dvec2x2(rng: &mut R) -> nalgebra::Vector2 { [random_f64x2(rng), random_f64x2(rng)].into() } - fn random_na_dvec2x4(rng: &mut R) -> nalgebra::Vector2 { + fn random_na_dvec2x4(rng: &mut R) -> nalgebra::Vector2 { [random_f64x4(rng), random_f64x4(rng)].into() } - fn random_na_dvec2x8(rng: &mut R) -> nalgebra::Vector2 { + fn random_na_dvec2x8(rng: &mut R) -> nalgebra::Vector2 { [random_f64x8(rng), random_f64x8(rng)].into() } - fn random_na_dvec3x2(rng: &mut R) -> nalgebra::Vector3 { + fn random_na_dvec3x2(rng: &mut R) -> nalgebra::Vector3 { [random_f64x2(rng), random_f64x2(rng), random_f64x2(rng)].into() } - fn random_na_dvec3x4(rng: &mut R) -> nalgebra::Vector3 { + fn random_na_dvec3x4(rng: &mut R) -> nalgebra::Vector3 { [random_f64x4(rng), random_f64x4(rng), random_f64x4(rng)].into() } - fn random_na_dvec3x8(rng: &mut R) -> nalgebra::Vector3 { + fn random_na_dvec3x8(rng: &mut R) -> nalgebra::Vector3 { [random_f64x8(rng), random_f64x8(rng), random_f64x8(rng)].into() } - fn random_na_mat2x4(rng: &mut R) -> nalgebra::Matrix2 { + fn random_na_mat2x4(rng: &mut R) -> nalgebra::Matrix2 { nalgebra::Matrix2::from_fn(|_, _| random_f32x4(rng)) } - fn random_na_mat3x4(rng: &mut R) -> nalgebra::Matrix3 { + fn random_na_mat3x4(rng: &mut R) -> nalgebra::Matrix3 { nalgebra::Matrix3::from_fn(|_, _| random_f32x4(rng)) } - fn random_na_mat4x4(rng: &mut R) -> nalgebra::Matrix4 { + fn random_na_mat4x4(rng: &mut R) -> nalgebra::Matrix4 { nalgebra::Matrix4::from_fn(|_, _| random_f32x4(rng)) } - fn random_na_mat2x8(rng: &mut R) -> nalgebra::Matrix2 { + fn random_na_mat2x8(rng: &mut R) -> nalgebra::Matrix2 { nalgebra::Matrix2::from_fn(|_, _| random_f32x8(rng)) } - fn random_na_mat3x8(rng: &mut R) -> nalgebra::Matrix3 { + fn random_na_mat3x8(rng: &mut R) -> nalgebra::Matrix3 { nalgebra::Matrix3::from_fn(|_, _| random_f32x8(rng)) } - fn random_na_mat4x8(rng: &mut R) -> nalgebra::Matrix4 { + fn random_na_mat4x8(rng: &mut R) -> nalgebra::Matrix4 { nalgebra::Matrix4::from_fn(|_, _| random_f32x8(rng)) } - fn random_na_mat2x16(rng: &mut R) -> nalgebra::Matrix2 { + fn random_na_mat2x16(rng: &mut R) -> nalgebra::Matrix2 { nalgebra::Matrix2::from_fn(|_, _| random_f32x16(rng)) } - fn random_na_mat3x16(rng: &mut R) -> nalgebra::Matrix3 { + fn random_na_mat3x16(rng: &mut R) -> nalgebra::Matrix3 { nalgebra::Matrix3::from_fn(|_, _| random_f32x16(rng)) } - fn random_na_mat4x16(rng: &mut R) -> nalgebra::Matrix4 { + fn random_na_mat4x16(rng: &mut R) -> nalgebra::Matrix4 { nalgebra::Matrix4::from_fn(|_, _| random_f32x16(rng)) } - fn random_f32x4(rng: &mut R) -> f32x4 { - rng.gen::<[f32; 4]>().into() + fn random_f32x4(rng: &mut R) -> f32x4 { + rng.random::<[f32; 4]>().into() } - fn random_f32x8(rng: &mut R) -> f32x8 { - rng.gen::<[f32; 8]>().into() + fn random_f32x8(rng: &mut R) -> f32x8 { + rng.random::<[f32; 8]>().into() } - fn random_f32x16(rng: &mut R) -> f32x16 { - rng.gen::<[f32; 16]>().into() + fn random_f32x16(rng: &mut R) -> f32x16 { + rng.random::<[f32; 16]>().into() } - fn random_f64x2(rng: &mut R) -> f64x2 { - rng.gen::<[f64; 2]>().into() + fn random_f64x2(rng: &mut R) -> f64x2 { + rng.random::<[f64; 2]>().into() } - fn random_f64x4(rng: &mut R) -> f64x4 { - rng.gen::<[f64; 4]>().into() + fn random_f64x4(rng: &mut R) -> f64x4 { + rng.random::<[f64; 4]>().into() } - fn random_f64x8(rng: &mut R) -> f64x8 { - rng.gen::<[f64; 8]>().into() + fn random_f64x8(rng: &mut R) -> f64x8 { + rng.random::<[f64; 8]>().into() } } #[cfg(feature = "static-math")] pub mod static_math_support { use super::BenchValue; - use rand::Rng; + use rand::RngExt; use static_math; use static_math::matrix2x2::M22; use static_math::matrix3x3::M33; @@ -771,13 +771,13 @@ pub mod static_math_support { fn random_nonzero_f32(rng: &mut R) -> f32 where - R: Rng, + R: RngExt, { - rng.gen_range(0.1..1.0) + rng.random_range(0.1..1.0) } impl BenchValue for M22 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let a = random_nonzero_f32(rng); let b = random_nonzero_f32(rng); let c = random_nonzero_f32(rng); @@ -787,7 +787,7 @@ pub mod static_math_support { } impl BenchValue for V2 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let a = random_nonzero_f32(rng); let b = random_nonzero_f32(rng); V2::new([a, b]) @@ -795,7 +795,7 @@ pub mod static_math_support { } impl BenchValue for M33 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let a_00 = random_nonzero_f32(rng); let a_01 = random_nonzero_f32(rng); let a_02 = random_nonzero_f32(rng); @@ -809,7 +809,7 @@ pub mod static_math_support { } } impl BenchValue for V3 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let a = random_nonzero_f32(rng); let b = random_nonzero_f32(rng); let c = random_nonzero_f32(rng); @@ -817,7 +817,7 @@ pub mod static_math_support { } } impl BenchValue for M44 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let a1 = random_nonzero_f32(rng); let a2 = random_nonzero_f32(rng); let a3 = random_nonzero_f32(rng); @@ -844,7 +844,7 @@ pub mod static_math_support { } impl BenchValue for V4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let a = random_nonzero_f32(rng); let b = random_nonzero_f32(rng); let c = random_nonzero_f32(rng); @@ -854,7 +854,7 @@ pub mod static_math_support { } impl BenchValue for Quaternion { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let q0 = random_nonzero_f32(rng); let q1 = random_nonzero_f32(rng); let q2 = random_nonzero_f32(rng); @@ -870,79 +870,79 @@ pub mod ultraviolet_support { use ultraviolet::*; impl BenchValue for Vec2x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Vec2x4::new( - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), ) } } impl BenchValue for Vec2x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Vec2x8::new( - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), ) } } impl BenchValue for Vec3x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Vec3x4::new( - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), ) } } impl BenchValue for Vec3x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Vec3x8::new( - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), ) } } impl BenchValue for Vec4x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Vec4x4::new( - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), - ultraviolet::f32x4::from(rng.gen::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), + ultraviolet::f32x4::from(rng.random::<[f32; 4]>()), ) } } impl BenchValue for Vec4x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Vec4x8::new( - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), - ultraviolet::f32x8::from(rng.gen::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), + ultraviolet::f32x8::from(rng.random::<[f32; 8]>()), ) } } impl BenchValue for Mat2x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat2x4::new(Vec2x4::random_value(rng), Vec2x4::random_value(rng)) } } impl BenchValue for Mat2x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat2x8::new(Vec2x8::random_value(rng), Vec2x8::random_value(rng)) } } impl BenchValue for Mat3x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat3x4::new( Vec3x4::random_value(rng), Vec3x4::random_value(rng), @@ -952,7 +952,7 @@ pub mod ultraviolet_support { } impl BenchValue for Mat3x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat3x8::new( Vec3x8::random_value(rng), Vec3x8::random_value(rng), @@ -962,7 +962,7 @@ pub mod ultraviolet_support { } impl BenchValue for Mat4x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat4x4::new( Vec4x4::random_value(rng), Vec4x4::random_value(rng), @@ -973,7 +973,7 @@ pub mod ultraviolet_support { } impl BenchValue for Mat4x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat4x8::new( Vec4x8::random_value(rng), Vec4x8::random_value(rng), @@ -984,7 +984,7 @@ pub mod ultraviolet_support { } impl BenchValue for Rotor2x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let angle = f32x4::from([ crate::glam_support::random_angle_radians(rng), crate::glam_support::random_angle_radians(rng), @@ -996,7 +996,7 @@ pub mod ultraviolet_support { } impl BenchValue for Rotor2x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let angle = f32x8::from([ crate::glam_support::random_angle_radians(rng), crate::glam_support::random_angle_radians(rng), @@ -1012,7 +1012,7 @@ pub mod ultraviolet_support { } impl BenchValue for Rotor3x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let yaw = f32x4::from([ crate::glam_support::random_angle_radians(rng), crate::glam_support::random_angle_radians(rng), @@ -1036,7 +1036,7 @@ pub mod ultraviolet_support { } impl BenchValue for Rotor3x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let yaw = f32x8::from([ crate::glam_support::random_angle_radians(rng), crate::glam_support::random_angle_radians(rng), @@ -1072,7 +1072,7 @@ pub mod ultraviolet_support { } impl BenchValue for Isometry2x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let tra = Vec2x4::random_value(rng); let rot = Rotor2x4::random_value(rng); Isometry2x4::new(tra, rot) @@ -1080,7 +1080,7 @@ pub mod ultraviolet_support { } impl BenchValue for Isometry2x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let tra = Vec2x8::random_value(rng); let rot = Rotor2x8::random_value(rng); Isometry2x8::new(tra, rot) @@ -1088,7 +1088,7 @@ pub mod ultraviolet_support { } impl BenchValue for Isometry3x4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let tra = Vec3x4::random_value(rng); let rot = Rotor3x4::random_value(rng); Isometry3x4::new(tra, rot) @@ -1096,7 +1096,7 @@ pub mod ultraviolet_support { } impl BenchValue for Isometry3x8 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let tra = Vec3x8::random_value(rng); let rot = Rotor3x8::random_value(rng); Isometry3x8::new(tra, rot) @@ -1104,31 +1104,31 @@ pub mod ultraviolet_support { } impl BenchValue for Vec2 { - fn random_value(rng: &mut R) -> Self { - Vec2::new(rng.gen(), rng.gen()) + fn random_value(rng: &mut R) -> Self { + Vec2::new(rng.random(), rng.random()) } } impl BenchValue for Vec3 { - fn random_value(rng: &mut R) -> Self { - Vec3::new(rng.gen(), rng.gen(), rng.gen()) + fn random_value(rng: &mut R) -> Self { + Vec3::new(rng.random(), rng.random(), rng.random()) } } impl BenchValue for Vec4 { - fn random_value(rng: &mut R) -> Self { - Vec4::new(rng.gen::(), rng.gen(), rng.gen(), rng.gen()) + fn random_value(rng: &mut R) -> Self { + Vec4::new(rng.random::(), rng.random(), rng.random(), rng.random()) } } impl BenchValue for Mat2 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat2::new(Vec2::random_value(rng), Vec2::random_value(rng)) } } impl BenchValue for Mat3 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat3::new( Vec3::random_value(rng), Vec3::random_value(rng), @@ -1138,7 +1138,7 @@ pub mod ultraviolet_support { } impl BenchValue for Mat4 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { Mat4::new( Vec4::random_value(rng), Vec4::random_value(rng), @@ -1149,14 +1149,14 @@ pub mod ultraviolet_support { } impl BenchValue for Rotor2 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let angle = crate::glam_support::random_angle_radians(rng); Rotor2::from_angle(angle) } } impl BenchValue for Rotor3 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let yaw = crate::glam_support::random_angle_radians(rng); let pitch = crate::glam_support::random_angle_radians(rng); let roll = crate::glam_support::random_angle_radians(rng); @@ -1165,7 +1165,7 @@ pub mod ultraviolet_support { } impl BenchValue for Isometry2 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let tra = Vec2::random_value(rng); let rot = Rotor2::random_value(rng); Isometry2::new(tra, rot) @@ -1173,7 +1173,7 @@ pub mod ultraviolet_support { } impl BenchValue for Isometry3 { - fn random_value(rng: &mut R) -> Self { + fn random_value(rng: &mut R) -> Self { let tra = Vec3::random_value(rng); let rot = Rotor3::random_value(rng); Isometry3::new(tra, rot) @@ -1185,7 +1185,7 @@ pub mod ultraviolet_support { pub mod euclid_support { use super::mint_support::*; use super::BenchValue; - use rand::Rng; + use rand::RngExt; impl_bench_value!(euclid::Point2D, random_euclid_point2); impl_bench_value!(euclid::Point3D, random_euclid_point3); @@ -1198,30 +1198,30 @@ pub mod euclid_support { // euclid random functions ---------------------------------------------------- fn random_euclid_vec2(rng: &mut R) -> euclid::Vector2D where - R: Rng, + R: RngExt, { - let (x, y) = rng.gen::<(f32, f32)>().into(); + let (x, y) = rng.random::<(f32, f32)>().into(); euclid::vec2(x, y) } fn random_euclid_point2(rng: &mut R) -> euclid::Point2D where - R: Rng, + R: RngExt, { random_euclid_vec2(rng).to_point() } fn random_euclid_vec3(rng: &mut R) -> euclid::Vector3D where - R: Rng, + R: RngExt, { - let (x, y, z) = rng.gen::<(f32, f32, f32)>().into(); + let (x, y, z) = rng.random::<(f32, f32, f32)>().into(); euclid::vec3(x, y, z) } fn random_euclid_point3(rng: &mut R) -> euclid::Point3D where - R: Rng, + R: RngExt, { random_euclid_vec3(rng).to_point() } @@ -1230,7 +1230,7 @@ pub mod euclid_support { rng: &mut R, ) -> euclid::Rotation3D where - R: Rng, + R: RngExt, { let mq = random_mint_quat(rng); euclid::Rotation3D::quaternion(mq.v.x, mq.v.y, mq.v.z, mq.s) @@ -1240,7 +1240,7 @@ pub mod euclid_support { rng: &mut R, ) -> euclid::Transform2D where - R: Rng, + R: RngExt, { let m = random_mint_homogeneous_mat3(rng); euclid::Transform2D::new(m.x.x, m.x.y, m.x.z, m.y.x, m.y.y, m.y.z) @@ -1250,7 +1250,7 @@ pub mod euclid_support { rng: &mut R, ) -> euclid::Transform3D where - R: Rng, + R: RngExt, { let m = random_mint_homogeneous_mat4(rng); euclid::Transform3D::new( @@ -1275,7 +1275,7 @@ pub mod vek_support { // fn random_vek_invertible_mat4(rng: &mut R) -> vek::mat::repr_simd::column_major::Mat4 // where - // R: Rng, + // R: RngExt, // { // let mm = random_homogeneous_mat4(rng); // vek::mat::repr_simd::column_major::Mat4::from_col_array(mm.into()) @@ -1283,17 +1283,17 @@ pub mod vek_support { // fn random_vek_vec3(rng: &mut R) -> vek::vec::repr_simd::Vec3 // where - // R: Rng, + // R: RngExt, // { - // let v: [f32; 3] = rng.gen::().into(); + // let v: [f32; 3] = rng.random::().into(); // v.into() // } // fn random_vek_vec4(rng: &mut R) -> vek::vec::repr_simd::Vec4 // where - // R: Rng, + // R: RngExt, // { - // let v: [f32; 4] = rng.gen::().into(); + // let v: [f32; 4] = rng.random::().into(); // v.into() // } @@ -1310,7 +1310,7 @@ pub mod vek_support { pub mod pathfinder_support { use super::mint_support::*; use super::BenchValue; - use rand::Rng; + use rand::RngExt; impl_bench_value!(pathfinder_geometry::vector::Vector2F, random_pf_vec2); impl_bench_value!(pathfinder_geometry::vector::Vector4F, random_pf_vec4); @@ -1326,21 +1326,21 @@ pub mod pathfinder_support { pub fn random_pf_vec2(rng: &mut R) -> pathfinder_geometry::vector::Vector2F where - R: Rng, + R: RngExt, { - pathfinder_geometry::vector::Vector2F::new(rng.gen(), rng.gen()) + pathfinder_geometry::vector::Vector2F::new(rng.random(), rng.random()) } pub fn random_pf_vec4(rng: &mut R) -> pathfinder_geometry::vector::Vector4F where - R: Rng, + R: RngExt, { - pathfinder_geometry::vector::Vector4F::new(rng.gen(), rng.gen(), rng.gen(), rng.gen()) + pathfinder_geometry::vector::Vector4F::new(rng.random(), rng.random(), rng.random(), rng.random()) } pub fn random_pf_mat2(rng: &mut R) -> pathfinder_geometry::transform2d::Matrix2x2F where - R: Rng, + R: RngExt, { let mat = random_mint_invertible_mat2(rng); pathfinder_geometry::transform2d::Matrix2x2F::row_major(mat.x.x, mat.y.x, mat.x.y, mat.y.y) @@ -1348,7 +1348,7 @@ pub mod pathfinder_support { pub fn random_pf_mat3(rng: &mut R) -> pathfinder_geometry::transform2d::Transform2F where - R: Rng, + R: RngExt, { let mat = random_mint_homogeneous_mat3(rng); pathfinder_geometry::transform2d::Transform2F::row_major( @@ -1358,7 +1358,7 @@ pub mod pathfinder_support { pub fn random_pf_mat4(rng: &mut R) -> pathfinder_geometry::transform3d::Transform4F where - R: Rng, + R: RngExt, { let mat = random_mint_homogeneous_mat4(rng); pathfinder_geometry::transform3d::Transform4F::row_major( From e48a6315a91c20467866174eadf7428a23333b55 Mon Sep 17 00:00:00 2001 From: Cameron Hart Date: Sun, 26 Jul 2026 17:03:36 +1200 Subject: [PATCH 2/2] Fix after-success.sh --- after-success.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/after-success.sh b/after-success.sh index e9d256c..0c71de5 100644 --- a/after-success.sh +++ b/after-success.sh @@ -11,7 +11,10 @@ git checkout master && cargo bench --bench eulerbench -- --noplot --save-baseline before && # Bench current branch -git checkout $GITHUB_SHA && +# For PRs, GITHUB_SHA is a merge commit that doesn't exist in a fresh clone. +# Use GITHUB_HEAD_REF (the branch name) for PRs, fall back to GITHUB_SHA for pushes. +CHECKOUT="${GITHUB_HEAD_REF:-$GITHUB_SHA}" +git checkout "$CHECKOUT" && cargo bench --bench eulerbench -- --noplot --save-baseline after && # Install https://github.com/BurntSushi/critcmp