PairedBench vMulPerf(int samples, long cycles) { var lhs1 = RVec <double>(samples); var rhs1 = RVec <double>(samples); var dst1 = RowVectors.blockalloc <double>(samples); var sw1 = Time.stopwatch(true); for (var i = 0; i < cycles; i++) { Calcs.mul(lhs1, rhs1, dst1.Unblocked); } var time1 = BenchmarkRecord.Define(cycles, Time.snapshot(sw1), "gmath"); var lhs2 = lhs1.Replicate(); var rhs2 = rhs1.Replicate(); var dst2 = dst1.Replicate(); var sw2 = Time.stopwatch(true); for (var i = 0; i < cycles; i++) { mkl.mul(lhs2, rhs2, ref dst2); } var time2 = BenchmarkRecord.Define(cycles, Time.snapshot(sw2), "mkl"); return(time1, time2); }
void rng_bench <T>(IDataStream <T> stream, [CallerMemberName] string caller = null) where T : unmanaged { var segment = Pow2.T08; var total = Pow2.T17; var stats = StatCollector.Create(0.0); var sw = stopwatch(false); for (var i = 0; i < total; i += segment) { sw.Start(); var sample = stream.TakeArray(segment); sw.Stop(); for (var j = 0; j < segment; j++) { stats.Collect(Numeric.force <T, double>(sample[j])); } } var opname = $"{caller}<{typeof(T).DisplayName()}>"; Deposit(BenchmarkRecord.Define(total, sw.Elapsed, opname)); }