Benchmark MulMat4Vec4

This commit is contained in:
bloeys
2021-11-05 07:51:04 +04:00
parent 2bdd7b2d02
commit 390222a18d
2 changed files with 38 additions and 3 deletions

24
main.go
View File

@ -96,4 +96,28 @@ func main() {
println("V6: " + v6.String())
v6.Normalize()
println("V6 Normal: " + v6.String())
//Mat2Vec2
mat2A := gglm.Mat2{
Data: [4]float32{
1, 2,
3, 4,
},
}
vec2A := gglm.Vec2{Data: [2]float32{1, 2}}
println(gglm.MulMat2Vec2(&mat2A, &vec2A).String())
//Mat3Vec3
mat3A := gglm.Mat3{
Data: [9]float32{
1, 2, 3,
4, 5, 6,
7, 8, 9,
},
}
vec3A := gglm.Vec3{Data: [3]float32{1, 2, 3}}
lol := gglm.MulMat3Vec3(&mat3A, &vec3A)
println(lol.String())
}

View File

@ -7,9 +7,10 @@ import (
)
var (
dotVec2Result float32 = 0
dotVec3Result float32 = 0
crossResult *gglm.Vec3
dotVec2Result float32 = 0
dotVec3Result float32 = 0
crossResult *gglm.Vec3
mulMat4Vec4Res *gglm.Vec4
)
func BenchmarkDotVec2(b *testing.B) {
@ -71,3 +72,13 @@ func BenchmarkMulMat4(b *testing.B) {
m1.Mul(m2)
}
}
func BenchmarkMulMat4Vec4(b *testing.B) {
m1 := gglm.NewMat4Id()
v1 := gglm.Vec4{}
for i := 0; i < b.N; i++ {
mulMat4Vec4Res = gglm.MulMat4Vec4(m1, &v1)
}
}