public void PerformanceTestStructVsClassMethod(UInt32 runCount) { long before; XYClass c = new XYClass(); XYStruct s = new XYStruct(); // // Run once to jit the code // c.TestMe(); s.TestMe(); for (UInt32 run = 0; run < runCount; run++) { Console.WriteLine("Run {0}", run); before = Stopwatch.GetTimestamp(); for (int i = 0; i < 10000000; i++) { c.TestMe(); } Console.WriteLine("Class: " + (Stopwatch.GetTimestamp() - before).StopwatchTicksAsDoubleMilliseconds()); PrintGC("Class"); before = Stopwatch.GetTimestamp(); for (int i = 0; i < 10000000; i++) { s.TestMe(); } Console.WriteLine("Struct: " + (Stopwatch.GetTimestamp() - before).StopwatchTicksAsDoubleMilliseconds()); PrintGC("Struct"); } }
public void JsonStructMisMatchTest() { XYStruct xy = new XYStruct { x = 12, y = 34 }; string json = JsonUtility.ToJson(xy); Debug.Log(json); BaseJsonable result = JsonUtility.FromJson <BaseJsonable>(json); Assert.AreEqual(12, result.x); }
void ReadVariables(ref XYStruct s) { Int32 x = s.a; Int32 y = s.b; }
XYStruct ReturnMe(XYStruct s) { return(s); }