Created
July 13, 2016 01:01
-
-
Save mellinoe/5af3ae7db013a6ab740fc8b80910b1b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void Matrix4x4ByValue() | |
{ | |
Matrix4x4_Local m1 = Matrix4x4_Local.Identity; | |
Matrix4x4_Local m2 = Matrix4x4_Local.CreateScale(5, 6, 7); | |
Matrix4x4_Local m3 = Matrix4x4_Local.CreateTranslation(-10, -12, -14); | |
Matrix4x4_Local m4 = Matrix4x4_Local.CreateFromYawPitchRoll(1.5f, 2.5f, 3.5f); | |
Matrix4x4_Local result = Matrix4x4_Local.Multiply(m1, m2); | |
result = Matrix4x4_Local.Multiply(result, m3); | |
result = Matrix4x4_Local.Multiply(result, m4); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void Matrix4x4ByRef() | |
{ | |
Matrix4x4_Local m1 = Matrix4x4_Local.Identity; | |
Matrix4x4_Local m2; Matrix4x4_Local.CreateScale(5, 6, 7, out m2); | |
Matrix4x4_Local m3; Matrix4x4_Local.CreateTranslation(-10, -12, -14, out m3); | |
Matrix4x4_Local m4; Matrix4x4_Local.CreateFromYawPitchRoll(1.5f, 2.5f, 3.5f, out m4); | |
Matrix4x4_Local result; | |
Matrix4x4_Local.Multiply(ref m1, ref m2, out result); | |
Matrix4x4_Local.Multiply(ref result, ref m3, out result); | |
Matrix4x4_Local.Multiply(ref result, ref m4, out result); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void QuaterionByValue() | |
{ | |
float yaw = 1.5f; | |
float pitch = 2.5f; | |
float roll = 3.5f; | |
Quaternion_Local rotation1 = Quaternion_Local.CreateFromYawPitchRoll(yaw, pitch, roll); | |
Quaternion_Local rotation2 = Quaternion_Local.CreateFromYawPitchRoll(yaw, pitch, roll); | |
Quaternion_Local rotation3 = Quaternion_Local.CreateFromAxisAngle(Vector3_Local.UnitX, 3f) * Quaternion_Local.CreateFromAxisAngle(new Vector3_Local(5, 6, 7), 10f); | |
Vector4_Local point = new Vector4_Local(2, 4, -6, -8); | |
point = Vector4_Local.Transform(point, rotation1); | |
point = Vector4_Local.Transform(point, rotation2); | |
point = Vector4_Local.Transform(point, rotation3); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void QuaterionByRef() | |
{ | |
float yaw = 1.5f; | |
float pitch = 2.5f; | |
float roll = 3.5f; | |
Quaternion_Local rotation1; Quaternion_Local.CreateFromYawPitchRoll(yaw, pitch, roll, out rotation1); | |
Quaternion_Local rotation2; Quaternion_Local.CreateFromYawPitchRoll(yaw, pitch, roll, out rotation2); | |
Quaternion_Local rotation3; | |
Quaternion_Local temp1, temp2; | |
Vector3_Local axis1 = Vector3_Local.UnitX; | |
Vector3_Local axis2 = new Vector3_Local(5, 6, 7); | |
Quaternion_Local.CreateFromAxisAngle(ref axis1, 3f, out temp1); | |
Quaternion_Local.CreateFromAxisAngle(ref axis2, 10f, out temp2); | |
Quaternion_Local.Multiply(ref temp1, ref temp2, out rotation3); | |
Vector4_Local point = new Vector4_Local(2, 4, -6, -8); | |
Vector4_Local.Transform(ref point, ref rotation1, out point); | |
Vector4_Local.Transform(ref point, ref rotation2, out point); | |
Vector4_Local.Transform(ref point, ref rotation3, out point); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void Vector3ByValue() | |
{ | |
Vector3_Local value1 = new Vector3_Local(1, 2, 3); | |
Vector3_Local value2 = new Vector3_Local(-10, -5, 5); | |
Vector3_Local value3 = new Vector3_Local(.3f, .6f, -1.9f); | |
Vector3_Local cross = Vector3_Local.Cross(value1, value2); | |
cross = Vector3_Local.Cross(cross, value3); | |
cross = Vector3_Local.Multiply(cross, value1); | |
cross = Vector3_Local.Lerp(cross, Vector3_Local.Zero, 0.3f); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void Vector3ByRef() | |
{ | |
Vector3_Local value1 = new Vector3_Local(1, 2, 3); | |
Vector3_Local value2 = new Vector3_Local(-10, -5, 5); | |
Vector3_Local value3 = new Vector3_Local(.3f, .6f, -1.9f); | |
Vector3_Local cross; | |
Vector3_Local.Cross(ref value1, ref value2, out cross); | |
Vector3_Local.Cross(ref cross, ref value3, out cross); | |
Vector3_Local.Multiply(ref cross, ref value1, out cross); | |
var zero = Vector3_Local.Zero; | |
Vector3_Local.Lerp(ref cross, ref zero, 0.3f, out cross); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void Vector3SimpleAddByValue() | |
{ | |
Vector3_Local value1 = new Vector3_Local(1, 2, 3); | |
Vector3_Local value2 = new Vector3_Local(-10, -5, 5); | |
Vector3_Local sum = Vector3_Local.Add(value1, value2); | |
} | |
[Benchmark] | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static void Vector3SimpleAddByRef() | |
{ | |
Vector3_Local value1 = new Vector3_Local(1, 2, 3); | |
Vector3_Local value2 = new Vector3_Local(-10, -5, 5); | |
Vector3_Local sum; Vector3_Local.Add(ref value1, ref value2, out sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment