private void Test(int length, int bins, FillArrayType type) { // setup: var data = new int[length]; Utils.FillArray(data, type); // when: var cpuResult = Utils.Histogram(data, bins); var gpuResult = gpuHist.Process(data, bins); // then: Assert.AreEqual(gpuResult.Length, bins); Assert.AreEqual(Utils.Reduce(gpuResult), length); for (var i = 0; i < bins; ++i) { Assert.AreEqual(gpuResult[i], cpuResult[i], "not eq at=" + i); } }
// Update is called once per frame private void Update() { if (!Input.GetKeyDown(KeyCode.Return)) { return; } IntArray(ref data, size, type, maxValue); if (printArray) { LogUtils.PrintArray(data, histogram.GetType().Name + " In: "); } var sw = Stopwatch.StartNew(); var histo = histogram.Process(data, binsValue); sw.Stop(); LogUtils.PrintArray(histo, histogram.GetType().Name + "(" + sw.ElapsedMilliseconds + "ms):"); if (printArray) { LogUtils.PrintArray(Utils.Histogram(data, binsValue), histogram.GetType().Name + "Serial:"); } }