public void Test_Intersect_Between_Arrays_Comparison_Linear_Search() { long averageMs = 0; long averageTicks = 0; int count = 0; Console.WriteLine("Test_Intersect_Between_Arrays_Linear_Search_Average"); for (var i = 0; i < COMPARISON_LOOP; i++) { var stopWatch = new Stopwatch(); stopWatch.Start(); var intersection = Intersector.IntersectionWithLinearSearch(colorsArray, namesArray, formatFunction: (i1, i2) => new string[] { i1[0], i1[1], i2[1] }); stopWatch.Stop(); Console.WriteLine($"Ran in {stopWatch.ElapsedTicks} ticks,{stopWatch.ElapsedMilliseconds}ms"); if (i != 0) { averageTicks += stopWatch.ElapsedTicks; averageMs += stopWatch.ElapsedMilliseconds; count++; } } averageMs = averageMs / count; averageTicks = averageTicks / count; Console.WriteLine($"Average in {averageTicks} ticks,{averageMs}ms"); }
public void Test_Intersect_Between_Arrays_Linear_Search() { var intersection = Intersector.IntersectionWithLinearSearch(colorsArray, namesArray, formatFunction: (i1, i2) => new string[] { i1[0], i1[1], i2[1] }); var result = string.Join("\r\n", intersection.Select(x => $"{x[0]},{x[1]},{x[2]}")); Assert.AreEqual(expectedResult, result); }