Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ nalgebra_f32x4 = ["nalgebra", "simba"]
nalgebra_f32x8 = ["nalgebra", "simba"]
nalgebra_wide = ["nalgebra_f32x4", "nalgebra_f32x8"]

scalar = ["cgmath", "nalgebra", "ultraviolet", "euclid", "vek", "pathfinder_geometry", "static-math"]
scalar = ["cgmath", "nalgebra", "ultraviolet", "euclid", "vek", "pathfinder_geometry"]

# nalgebra_wide fails to build due to packed_simd errors
# wide = ["glam_f32x1", "ultraviolet_wide", "nalgebra_wide"]
Expand Down Expand Up @@ -69,9 +69,6 @@ optional = true
version = "0.5.1"
optional = true

[dependencies.static-math]
version = "0.2.3"
optional = true

[dependencies.ultraviolet]
version = "0.10.0"
Expand Down
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ games and graphics development, including:
* [`euclid`][euclid]
* [`nalgebra`][nalgebra]
* [`pathfinder_geometry`][pathfinder_geometry]
* [`static-math`][static-math]
* [`ultraviolet`][ultraviolet]
* [`vek`][vek]

Expand All @@ -25,7 +24,6 @@ games and graphics development, including:
[glam]: https://github.com/bitshifter/glam-rs
[nalgebra]: https://nalgebra.org
[pathfinder_geometry]: https://crates.io/crates/pathfinder_geometry
[static-math]: https://crates.io/crates/static-math
[ultraviolet]: https://crates.io/crates/ultraviolet
[vek]: https://crates.io/crates/vek

Expand Down Expand Up @@ -167,7 +165,7 @@ run the benchmarks themselves and consider publishing their results.

The following is a table of benchmarks produced by `mathbench` comparing `glam`
performance to `cgmath`, `nalgebra`, `euclid`, `vek`, `pathfinder_geometry`,
`static-math` and `ultraviolet` on `f32` data.
and `ultraviolet` on `f32` data.

These benchmarks were performed on an [Intel i7-4710HQ] CPU on Linux. They were
compiled with the `1.56.1 (59eed8a2a 2021-11-01)` Rust compiler. Lower
Expand All @@ -181,7 +179,6 @@ The versions of the libraries tested were:
* `glam` - `0.20.1`
* `nalgebra` - `0.29.0`
* `pathfinder_geometry` - `0.5.1`
* `static-math` - `0.2.3`
* `ultraviolet` - `0.8.1`
* `vek` - `0.15.3` (`repr_c` types)

Expand All @@ -195,12 +192,12 @@ Run with the command:
cargo bench --features scalar scalar
```

| benchmark | glam | cgmath | nalgebra | euclid | vek | pathfinder | static-math | ultraviolet |
| benchmark | glam | cgmath | nalgebra | euclid | vek | pathfinder | ultraviolet |
|--------------------------------|-----------------|-----------------|-----------------|----------------|-----------------|-----------------|-----------------|-----------------|
| euler 2d x10000 | 16.23 us | 16.13 us | __9.954 us__ | 16.18 us | 16.2 us | 10.42 us | __9.97 us__ | 16.17 us |
| euler 3d x10000 | __15.95 us__ | 32.11 us | 32.13 us | 32.13 us | 32.13 us | __16.27 us__ | 32.16 us | 32.11 us |
| matrix2 determinant | __2.0386 ns__ | 2.0999 ns | 2.1018 ns | N/A | 2.0997 ns | 2.0987 ns | 2.0962 ns | 2.1080 ns |
| matrix2 inverse | __2.8226 ns__ | 8.4418 ns | 7.6303 ns | N/A | N/A | 3.3459 ns | 9.4636 ns | 5.8796 ns |
| euler 2d x10000 | 16.23 us | 16.13 us | __9.954 us__ | 16.18 us | 16.2 us | 10.42 us | 16.17 us |
| euler 3d x10000 | __15.95 us__ | 32.11 us | 32.13 us | 32.13 us | 32.13 us | __16.27 us__ | 32.11 us |
| matrix2 determinant | __2.0386 ns__ | 2.0999 ns | 2.1018 ns | N/A | 2.0997 ns | 2.0987 ns | 2.1080 ns |
| matrix2 inverse | __2.8226 ns__ | 8.4418 ns | 7.6303 ns | N/A | N/A | 3.3459 ns | 5.8796 ns |
| matrix2 mul matrix2 | __2.6036 ns__ | 5.0007 ns | 4.8172 ns | N/A | 9.3814 ns | __2.5516 ns__ | 4.7274 ns | 4.9428 ns |
| matrix2 mul vector2 x1 | 2.4904 ns | 2.6144 ns | 2.8714 ns | N/A | 4.2139 ns | __2.0839 ns__ | 2.8873 ns | 2.6250 ns |
| matrix2 mul vector2 x100 | 227.5271 ns | 243.3579 ns | 265.1698 ns | N/A | 400.6940 ns | __219.7127 ns__ | 267.8780 ns | 243.9880 ns |
Expand Down Expand Up @@ -469,7 +466,6 @@ won't pay the build cost twice (unless it's a different version).
| glam | 0.9.4 | 1.1 | 0.6 | 2 |
| nalgebra | 0.22.0 | 24.2 | 18.0 | 24 |
| pathfinder_geometry | 0.5.1 | 3.0 | 0.3 | 8 |
| static-math | 0.1.6 | 6.9 | 1.7 | 10 |
| ultraviolet | 0.5.1 | 2.5 | 1.3 | 4 |
| vek | 0.12.0 | 34.4 | 10.1 | 16 |

Expand Down
10 changes: 2 additions & 8 deletions benches/eulerbench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ fn bench_euler_3d(c: &mut Criterion) {
use nalgebra::{zero, Vector3};
bench_euler!(b, size, ty => Vector3<f32>, zero => zero(), dt => UPDATE_RATE);
});
bench_static_math!(group, size, |b, size| {
use static_math::vector3::V3;
bench_euler!(b, size, ty => V3<f32>, zero => V3::zeros(), dt => UPDATE_RATE);
});

bench_euclid!(group, size, |b, size| {
use euclid::{UnknownUnit, Vector3D};
bench_euler!(b, size, ty => Vector3D<f32, UnknownUnit>, zero => Vector3D::zero(), dt => UPDATE_RATE);
Expand Down Expand Up @@ -127,10 +124,7 @@ fn bench_euler_2d(c: &mut Criterion) {
use nalgebra::{zero, Vector2};
bench_euler!(b, size, ty => Vector2<f32>, zero => zero(), dt => UPDATE_RATE);
});
bench_static_math!(group, size, |b, size| {
use static_math::vector2::V2;
bench_euler!(b, size, ty => V2<f32>, zero => V2::zeros(), dt => UPDATE_RATE);
});

bench_euclid!(group, size, |b, size| {
use euclid::{UnknownUnit, Vector2D};
bench_euler!(b, size, ty => Vector2D<f32, UnknownUnit>, zero => Vector2D::zero(), dt => UPDATE_RATE);
Expand Down
34 changes: 6 additions & 28 deletions benches/matrix2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ fn bench_matrix2_ret_self(c: &mut Criterion) {
use vek::Mat2;
bench_unop!(b, op => ret_self, ty => Mat2<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix2x2::M22;
bench_unop!(b, op => ret_self, ty => M22<f32>)
});

bench_pathfinder!(group, |b| {
use pathfinder_geometry::transform2d::Matrix2x2F;
bench_unop!(b, op => ret_self, ty => Matrix2x2F)
Expand Down Expand Up @@ -87,11 +84,7 @@ fn bench_matrix2_transpose(c: &mut Criterion) {
use nalgebra::Matrix2;
bench_unop!(b, op => transpose, ty => Matrix2<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix2x2::M22;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => transpose, ty => M22<f32>)
});

bench_vek!(group, |b| {
use vek::Mat2;
bench_unop!(b, op => transposed, ty => Mat2<f32>)
Expand Down Expand Up @@ -146,11 +139,7 @@ fn bench_matrix2_determinant(c: &mut Criterion) {
use nalgebra::Matrix2;
bench_unop!(b, op => determinant, ty => Matrix2<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix2x2::M22;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => det, ty => M22<f32>)
});

bench_vek!(group, |b| {
use vek::Mat2;
bench_unop!(b, op => determinant, ty => Mat2<f32>)
Expand Down Expand Up @@ -199,11 +188,7 @@ fn bench_matrix2_inverse(c: &mut Criterion) {
use nalgebra::Matrix2;
bench_unop!(b, op => try_inverse, ty => Matrix2<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix2x2::M22;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => inverse, ty => M22<f32>)
});

bench_pathfinder!(group, |b| {
use pathfinder_geometry::transform2d::Matrix2x2F;
bench_unop!(b, op => inverse, ty => Matrix2x2F)
Expand Down Expand Up @@ -248,10 +233,7 @@ fn bench_matrix2_mul_matrix2(c: &mut Criterion) {
use nalgebra::Matrix2;
bench_binop!(b, op => mul, ty1 => Matrix2<f32>, ty2 => Matrix2<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix2x2::M22;
bench_binop!(b, op => mul, ty1 => M22<f32>, ty2 => M22<f32>)
});

bench_vek!(group, |b| {
use vek::Mat2;
bench_binop!(b, op => mul, ty1 => Mat2<f32>, ty2 => Mat2<f32>)
Expand Down Expand Up @@ -313,11 +295,7 @@ fn bench_matrix2_mul_vector2(c: &mut Criterion) {
use nalgebra::{Matrix2, Vector2};
bench_binop!(b, size, op => mul, ty1 => Matrix2<f32>, ty2 => Vector2<f32>)
});
bench_static_math!(group, size, |b, size| {
use static_math::matrix2x2::M22;
use static_math::vector2::V2;
bench_binop!(b, size, op => mul, ty1 => M22<f32>, ty2 => V2<f32>)
});

bench_vek!(group, size, |b, size| {
use vek::{Mat2, Vec2};
bench_binop!(b, size, op => mul, ty1 => Mat2<f32>, ty2 => Vec2<f32>)
Expand Down
34 changes: 6 additions & 28 deletions benches/matrix3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ fn bench_matrix3_ret_self(c: &mut Criterion) {
use nalgebra::Matrix3;
bench_unop!(b, op => ret_self, ty => Matrix3<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix3x3::M33;
bench_unop!(b, op => ret_self, ty => M33<f32>)
});

bench_vek!(group, |b| {
use vek::Mat3;
bench_unop!(b, op => ret_self, ty => Mat3<f32>)
Expand Down Expand Up @@ -82,11 +79,7 @@ fn bench_matrix3_transpose(c: &mut Criterion) {
use nalgebra::Matrix3;
bench_unop!(b, op => transpose, ty => Matrix3<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix3x3::M33;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => transpose, ty => M33<f32>)
});

bench_vek!(group, |b| {
use vek::Mat3;
bench_unop!(b, op => transposed, ty => Mat3<f32>)
Expand Down Expand Up @@ -141,11 +134,7 @@ fn bench_matrix3_determinant(c: &mut Criterion) {
use nalgebra::Matrix3;
bench_unop!(b, op => determinant, ty => Matrix3<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix3x3::M33;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => det, ty => M33<f32>)
});

bench_vek!(group, |b| {
use vek::Mat3;
bench_unop!(b, op => determinant, ty => Mat3<f32>)
Expand Down Expand Up @@ -190,11 +179,7 @@ fn bench_matrix3_inverse(c: &mut Criterion) {
use nalgebra::Matrix3;
bench_unop!(b, op => try_inverse, ty => Matrix3<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix3x3::M33;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => inverse, ty => M33<f32>)
});

group.finish();
}

Expand Down Expand Up @@ -235,10 +220,7 @@ fn bench_matrix3_mul_matrix3(c: &mut Criterion) {
use nalgebra::Matrix3;
bench_binop!(b, op => mul, ty1 => Matrix3<f32>, ty2 => Matrix3<f32>, param => by_ref)
});
bench_static_math!(group, |b| {
use static_math::matrix3x3::M33;
bench_binop!(b, op => mul, ty1 => M33<f32>, ty2 => M33<f32>)
});

bench_vek!(group, |b| {
use vek::Mat3;
bench_binop!(b, op => mul, ty1 => Mat3<f32>, ty2 => Mat3<f32>)
Expand Down Expand Up @@ -296,11 +278,7 @@ fn bench_matrix3_mul_vector3(c: &mut Criterion) {
use nalgebra::{Matrix3, Vector3};
bench_binop!(b, size, op => mul, ty1 => Matrix3<f32>, ty2 => Vector3<f32>)
});
bench_static_math!(group, size, |b, size| {
use static_math::matrix3x3::M33;
use static_math::vector3::V3;
bench_binop!(b, size, op => mul, ty1 => M33<f32>, ty2 => V3<f32>)
});

bench_vek!(group, size, |b, size| {
use vek::{Mat3, Vec3};
bench_binop!(b, size, op => mul, ty1 => Mat3<f32>, ty2 => Vec3<f32>)
Expand Down
34 changes: 6 additions & 28 deletions benches/matrix4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ fn bench_matrix4_ret_self(c: &mut Criterion) {
use nalgebra::Matrix4;
bench_unop!(b, op => ret_self, ty => Matrix4<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix4x4::M44;
bench_unop!(b, op => ret_self, ty => M44<f32>)
});

bench_vek!(group, |b| {
use vek::Mat4;
bench_unop!(b, op => ret_self, ty => Mat4<f32>)
Expand Down Expand Up @@ -83,11 +80,7 @@ fn bench_matrix4_transpose(c: &mut Criterion) {
use nalgebra::Matrix4;
bench_unop!(b, op => transpose, ty => Matrix4<f32>);
});
bench_static_math!(group, |b| {
use static_math::matrix4x4::M44;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => transpose, ty => M44<f32>);
});

bench_vek!(group, |b| {
use vek::Mat4;
bench_unop!(b, op => transposed, ty => Mat4<f32>)
Expand Down Expand Up @@ -142,11 +135,7 @@ fn bench_matrix4_determinant(c: &mut Criterion) {
use nalgebra::Matrix4;
bench_unop!(b, op => determinant, ty => Matrix4<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix4x4::M44;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => det, ty => M44<f32>)
});

bench_euclid!(group, |b| {
use euclid::{Transform3D, UnknownUnit};
bench_unop!(b, op => determinant, ty => Transform3D<f32, UnknownUnit, UnknownUnit>)
Expand Down Expand Up @@ -195,11 +184,7 @@ fn bench_matrix4_inverse(c: &mut Criterion) {
use nalgebra::Matrix4;
bench_unop!(b, op => try_inverse, ty => Matrix4<f32>)
});
bench_static_math!(group, |b| {
use static_math::matrix4x4::M44;
use static_math::traits::LinearAlgebra;
bench_unop!(b, op => inverse, ty => M44<f32>)
});

bench_euclid!(group, |b| {
use euclid::{Transform3D, UnknownUnit};
bench_unop!(b, op => inverse, ty => Transform3D<f32, UnknownUnit, UnknownUnit>)
Expand Down Expand Up @@ -248,10 +233,7 @@ fn bench_matrix4_mul_matrix4(c: &mut Criterion) {
use nalgebra::Matrix4;
bench_binop!(b, op => mul, ty1 => Matrix4<f32>, ty2 => Matrix4<f32>, param => by_ref)
});
bench_static_math!(group, |b| {
use static_math::matrix4x4::M44;
bench_binop!(b, op => mul, ty1 => M44<f32>, ty2 => M44<f32>)
});

bench_euclid!(group, |b| {
use euclid::{Transform3D, UnknownUnit};
bench_binop!(b, op => then, ty => Transform3D<f32, UnknownUnit, UnknownUnit>, param => by_ref)
Expand Down Expand Up @@ -313,11 +295,7 @@ fn bench_matrix4_mul_vector4(c: &mut Criterion) {
use nalgebra::{Matrix4, Vector4};
bench_binop!(b, size, op => mul, ty1 => Matrix4<f32>, ty2 => Vector4<f32>)
});
bench_static_math!(group, size, |b, size| {
use static_math::matrix4x4::M44;
use static_math::vector4::V4;
bench_binop!(b, size, op => mul, ty1 => M44<f32>, ty2 => V4<f32>)
});

bench_vek!(group, size, |b, size| {
use vek::{Mat4, Vec4};
bench_binop!(b, size, op => mul, ty1 => Mat4<f32>, ty2 => Vec4<f32>)
Expand Down
21 changes: 4 additions & 17 deletions benches/rotation3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ fn bench_rotation3_nop(c: &mut Criterion) {
use nalgebra::UnitQuaternion;
bench_unop!(b, op => ret_self, ty => UnitQuaternion<f32>)
});
bench_static_math!(group, |b| {
use static_math::quaternion::Quaternion;
bench_unop!(b, op => ret_self, ty => Quaternion<f32>)
});

bench_vek!(group, |b| {
use vek::Quaternion;
bench_unop!(b, op => ret_self, ty => Quaternion<f32>)
Expand Down Expand Up @@ -84,10 +81,7 @@ fn bench_rotation3_inverse(c: &mut Criterion) {
use nalgebra::UnitQuaternion;
bench_unop!(b, op => conjugate, ty => UnitQuaternion<f32>)
});
bench_static_math!(group, |b| {
use static_math::quaternion::Quaternion;
bench_unop!(b, op => conj, ty => Quaternion<f32>)
});

bench_euclid!(group, |b| {
use euclid::{Rotation3D, UnknownUnit};
// euclid inverse assumes normalized quaternion, so it's just a conjugate
Expand Down Expand Up @@ -147,10 +141,7 @@ fn bench_rotation3_mul_rotation3(c: &mut Criterion) {
use nalgebra::UnitQuaternion;
bench_binop!(b, op => mul, ty1 => UnitQuaternion<f32>, ty2 => UnitQuaternion<f32>)
});
bench_static_math!(group, |b| {
use static_math::quaternion::Quaternion;
bench_binop!(b, op => mul, ty1 => Quaternion<f32>, ty2 => Quaternion<f32>)
});

bench_euclid!(group, |b| {
use euclid::{Rotation3D, UnknownUnit};
bench_binop!(b, op => then, ty => Rotation3D<f32, UnknownUnit, UnknownUnit>, param => by_ref)
Expand Down Expand Up @@ -211,11 +202,7 @@ fn bench_rotation3_mul_vector3(c: &mut Criterion) {
use nalgebra::{UnitQuaternion, Vector3};
bench_binop!(b, size, op => mul, ty1 => UnitQuaternion<f32>, ty2 => Vector3<f32>)
});
bench_static_math!(group, size, |b, size| {
use static_math::quaternion::Quaternion;
use static_math::vector3::V3;
bench_binop!(b, size, op => mul, ty1 => Quaternion<f32>, ty2 => V3<f32>)
});

bench_euclid!(group, size, |b, size| {
use euclid::{Point3D, Rotation3D, UnknownUnit};
bench_binop!(b, size, op => transform_point3d, ty1 => Rotation3D<f32, UnknownUnit, UnknownUnit>, ty2 => Point3D<f32, UnknownUnit>)
Expand Down
10 changes: 0 additions & 10 deletions benches/support/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,6 @@ macro_rules! bench_vek {
};
}

#[macro_export]
macro_rules! bench_static_math {
($group:ident, $closure:expr) => {
bench_lib!("static-math", $group, $closure)
};
($group:ident, $size:expr, $closure:expr) => {
bench_lib!("static-math", $group, $size, $closure)
};
}

#[macro_export]
macro_rules! bench_pathfinder {
($group:ident, $closure:expr) => {
Expand Down
Loading
Loading