public void MostFrequentFilter_NoDuplicates() { int[][] arrays = new int[NUMBER_OF_ARRAYS][]; int startValue = 1; for (int i = 0; i < arrays.Length; i++) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); startValue += arrays[i].Length; } var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, int.MaxValue); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == NUMBER_OF_ELEMENTS * NUMBER_OF_ARRAYS); int lastValue = 0; for (int i = 0; i < filter.Count; i++) { Assert.IsTrue(lastValue < filter[i]); lastValue = filter[i]; } }
public void MostFrequentFilter_DifferentLengthDuplicateValue() { int[][] arrays = new int[NUMBER_OF_ARRAYS][]; for (int i = 0; i < arrays.Length; i++) { arrays[i] = createArray(NUMBER_OF_ELEMENTS * (arrays.Length - i), 0, 1); } var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, int.MaxValue); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == NUMBER_OF_ELEMENTS); for (int i = 0; i < arrays[arrays.Length - 1].Length; i++) { Assert.IsTrue(filter[i] == arrays[arrays.Length - 1][i]); } }
public void MostFrequentFilter_AllDuplicates() { int[][] arrays = new int[NUMBER_OF_ARRAYS][]; for (int i = 0; i < arrays.Length; i++) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, 0, 1); } var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, int.MaxValue); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == NUMBER_OF_ELEMENTS); for (int i = 0; i < arrays[0].Length; i++) { Assert.IsTrue(filter[i].Equals(arrays[0][i])); } }
public void MostFrequentFilter_MaxResults() { int[][] arrays = new int[4][]; int startValue = 1; for (int i = 2; i >= 0; i -= 2) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); arrays[i + 1] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); startValue += arrays[i].Length; } var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, NUMBER_OF_ELEMENTS / 10); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == NUMBER_OF_ELEMENTS / 10); for (int i = 0; i < filter.Count - 1; i++) { Assert.IsTrue(filter[i] < filter[i+1]); } }
public void MostFrequentFilter_OneDuplicateValue() { int[][] arrays = new int[NUMBER_OF_ARRAYS][]; int startValue = 1; for (int i = 0; i < arrays.Length - 1; i++) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); startValue += arrays[i].Length; } arrays[arrays.Length - 1] = new int[] { arrays[0][NUMBER_OF_ELEMENTS / 2] }; var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, int.MaxValue); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == 1); Assert.IsTrue(filter[0] == arrays[arrays.Length - 1][0]); }
public void MostFrequentFilter_MaxResults() { int[][] arrays = new int[4][]; int startValue = 1; for (int i = 2; i >= 0; i -= 2) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); arrays[i + 1] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); startValue += arrays[i].Length; } var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, NUMBER_OF_ELEMENTS / 10); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == NUMBER_OF_ELEMENTS / 10); for (int i = 0; i < filter.Count - 1; i++) { Assert.IsTrue(filter[i] < filter[i + 1]); } }
public void MostFrequentFilter_OneDuplicateValue() { int[][] arrays = new int[NUMBER_OF_ARRAYS][]; int startValue = 1; for (int i = 0; i < arrays.Length - 1; i++) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); startValue += arrays[i].Length; } arrays[arrays.Length - 1] = new int[] { arrays[0][NUMBER_OF_ELEMENTS / 2] }; var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, int.MaxValue); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == 1); Assert.IsTrue(filter[0] == arrays[arrays.Length - 1][0]); }
public void MostFrequentFilter_NoDuplicates() { int[][] arrays = new int[NUMBER_OF_ARRAYS][]; int startValue = 1; for (int i = 0; i < arrays.Length; i++) { arrays[i] = createArray(NUMBER_OF_ELEMENTS, startValue, 1); startValue += arrays[i].Length; } var startTime = DateTime.UtcNow; var filter = new Controller.MostFrequentFilter(arrays, int.MaxValue); Console.WriteLine("Completed filter in '{0}ms'", (DateTime.UtcNow - startTime).TotalMilliseconds); Assert.IsTrue(filter.Count == NUMBER_OF_ELEMENTS * NUMBER_OF_ARRAYS); int lastValue = 0; for (int i = 0; i < filter.Count; i++) { Assert.IsTrue(lastValue < filter[i]); lastValue = filter[i]; } }