Beispiel #1
0
        void contract64f_bench()
        {
            var max = 250000ul;
            var n   = SampleSize;
            var sw  = stopwatch();
            var src = Random.Array <ulong>(n);

            sw.Start();
            for (var i = 0; i < n; i++)
            {
                contract(src[i], max);
            }
            sw.Stop();
            var time1 = OpTime.Define(n, snapshot(sw), "contract-f64");

            sw.Reset();
            sw.Start();
            for (var i = 0; i < n; i++)
            {
                src[i].Contract(max);
            }
            sw.Stop();
            var time2 = OpTime.Define(n, snapshot(sw), "contract-baseline");

            TracePerf((time1, time2));
        }
Beispiel #2
0
        /// <summary>
        /// Collects function evaluation timing
        /// </summary>
        /// <param name="f">The function to evaluate</param>
        /// <param name="label">The measurement label</param>
        /// <param name="labelPad">For tracing, the width of the measurement label</param>
        public void Measure(Func <int> f, [CallerMemberName] string label = null, int?labelPad = null)
        {
            var sw   = stopwatch();
            var ops  = f();
            var time = OpTime.Define(ops, snapshot(sw), label);

            Enqueue(time);

            if (TraceEnabled)
            {
                TracePerf(time.Format(labelPad));
            }
        }