public static void Main(string[] args) { Console.WriteLine("Pruebas de rendimiento"); int count = 100; int count2 = 1000000; List <SingleTest> tests = new List <SingleTest>(); List <IVec> vectors = new List <IVec>(); for (int i = 0; i < count2; i++) { vectors.Add(new Vec(i, i, i, i)); } List <Vec> vectors2 = new List <Vec>(); for (int i = 0; i < count2; i++) { vectors2.Add(new Vec(i, i, i, i)); } // BuffVec tests.Add(new SingleTest( "Test.BuffVec", () => { BuffVec sum = new BuffVec(); for (int i = 0; i < vectors.Count; i++) { sum.Add(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec (2)", () => { BuffVec sum = new BuffVec(); for (int i = 0; i < vectors2.Count; i++) { sum.Add(vectors2[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec.Add_2", () => { BuffVec sum = new BuffVec(); for (int i = 0; i < vectors.Count; i++) { sum.Add_2(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec.Add_2 (2) ", () => { BuffVec sum = new BuffVec(); for (int i = 0; i < vectors2.Count; i++) { sum.Add_2(vectors2[i]); } return(sum); }) ); // BuffVec2 // ***** 2a ***** tests.Add(new SingleTest( "Test.BuffVec2", () => { BuffVec_v2 sum = new BuffVec_v2(); for (int i = 0; i < vectors.Count; i++) { sum.Add(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec2 (2)", () => { BuffVec_v2 sum = new BuffVec_v2(); for (int i = 0; i < vectors2.Count; i++) { sum.Add(vectors2[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec2.Add_2", () => { BuffVec_v2 sum = new BuffVec_v2(); for (int i = 0; i < vectors.Count; i++) { sum.Add_2(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec2.Add_2 (2)", () => { BuffVec_v2 sum = new BuffVec_v2(); for (int i = 0; i < vectors2.Count; i++) { sum.Add_2(vectors2[i]); } return(sum); }) ); // Vec tests.Add(new SingleTest( "Test.Vec", () => { Vec sum = new Vec(); for (int i = 0; i < vectors.Count; i++) { sum = sum.Add(vectors[i]); } return(sum); }) ); // ***** Mejor rendimiento ***** tests.Add(new SingleTest( "Test.Vec (2)", () => { Vec sum = new Vec(); for (int i = 0; i < vectors2.Count; i++) { sum = sum.Add(vectors2[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.Vec.Add_2", () => { Vec sum = new Vec(); for (int i = 0; i < vectors.Count; i++) { sum = sum.Add_2(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.Vec.Add_2 (2)", () => { Vec sum = new Vec(); for (int i = 0; i < vectors2.Count; i++) { sum = sum.Add_2(vectors2[i]); } return(sum); }) ); // Ultimas pruebas tests.Add(new SingleTest( "Test.BuffVec2.Add_3", () => { BuffVec_v2 sum = new BuffVec_v2(); for (int i = 0; i < vectors.Count; i++) { sum.Add_3(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec2.Add_3 (2)", () => { BuffVec_v2 sum = new BuffVec_v2(); for (int i = 0; i < vectors2.Count; i++) { sum.Add_3(vectors2[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec.Add_3", () => { BuffVec sum = new BuffVec(); for (int i = 0; i < vectors.Count; i++) { sum.Add_3(vectors[i]); } return(sum); }) ); tests.Add(new SingleTest( "Test.BuffVec.Add_3 (2)", () => { BuffVec sum = new BuffVec(); for (int i = 0; i < vectors2.Count; i++) { sum.Add_3(vectors2[i]); } return(sum); }) ); /*SingleTest aux = tests[9]; * tests.Clear(); * tests.Add(aux);*/ foreach (SingleTest test in tests) { Measure(test, count); } Console.WriteLine("Resultado"); tests.Sort((a, b) => a.Time.CompareTo(b.Time)); long minTime = tests[0].Time; foreach (SingleTest test in tests) { Console.WriteLine("{0,-30} {1,10:F3} : {2,10}", test.Name, test.Time / (double)minTime, test.Time); } Console.ReadKey(); foreach (object result in tests[0].Results) { Console.WriteLine("" + result); } }