Files
stgsharp/源代码/StgSharpDebug/Debug.cs
T

144 lines
3.3 KiB
C#

using StgSharp.Math;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
namespace StgSharp
{
internal static class Program
{
internal unsafe static void Main(string[] args)
{
/**/
Matrix4x4 matrix = new Matrix4x4(
1,1,-1,2,
-1,-1,-4,1,
2,4,-6,1,
1,2,4,2
);
Console.WriteLine(matrix.Det());
/**/
System.Numerics.Matrix4x4 m = new System.Numerics.Matrix4x4(
1, 1, -1, 2,
-1, -1, -4, 1,
2, 4, -6, 1,
1, 2, 4, 2
);
Console.WriteLine(m.GetDeterminant());
/**/
int cycle = 1000;
int time = 10000;
for (int t = 0; t < cycle; t++)
{
Stopwatch sw = Stopwatch.StartNew();
sw.Start();
for (int i = 0; i < time; i++)
{
Matrix4x4 matrix4X4 = new Matrix4x4(
1, 1, -1, 2,
-1, -1, -4, 1,
2, 4, -6, 1,
1, 2, 4, 2
);
}
sw.Stop();
TimeSpan timeSpan = sw.Elapsed;
Console.WriteLine(timeSpan.TotalMilliseconds);
Stopwatch sw2 = new Stopwatch();
sw2.Start();
for (int i = 0; i < time; i++)
{
System.Numerics.Matrix4x4 test = new System.Numerics.Matrix4x4(
1, 1, -1, 2,
-1, -1, -4, 1,
2, 4, -6, 1,
1, 2, 4, 2
);
}
sw2.Stop();
TimeSpan timeSpan1 = sw2.Elapsed;
Console.WriteLine(timeSpan1.TotalMilliseconds);
Console.WriteLine();
}
/**/
/*
System.Numerics.Matrix4x4 smt1 = new System.Numerics.Matrix4x4(
1,2,3,4,
5,6,7,8,
1,2,3,4,
5,6,7,8
);
Matrix4x4 gmt1 = new Matrix4x4(
1, 2, 3, 4,
5, 6, 7, 8,
1, 2, 3, 4,
5, 6, 7, 8
);
Stopwatch s = new Stopwatch();
double cycle = 1e6;
for (int t = 0; t < 1000; t++)
{
s.Reset();
s.Start();
for (int i = 0; i < cycle; i++)
{
System.Numerics.Matrix4x4 ret = smt1 * smt1;
}
s.Stop();
TimeSpan span = s.Elapsed;
Console.WriteLine(span.TotalMilliseconds);
s.Reset();
s.Start();
for (int i = 0; i < cycle; i++)
{
Matrix4x4 ret = VectorCalc.Multiple(gmt1, gmt1);
}
s.Stop();
TimeSpan span1 = s.Elapsed;
Console.WriteLine(span1.TotalMilliseconds);
Console.WriteLine(t);
Console.WriteLine();
}
/**/
}
}
}