public Measurement RunIteration(IterationData data)
 {
     double nanoseconds = measure(data).Nanoseconds;
     var measurement = new Measurement(1, data.IterationMode, data.Index, data.InvokeCount * OperationsPerInvoke, nanoseconds);
     WriteLine(measurement.ToOutputLine());
     return measurement;
 }
Beispiel #2
0
 [PublicAPI] public static bool IsWorkload(this Measurement measurement) => measurement.IterationMode == IterationMode.Workload;
Beispiel #3
0
 public static bool Is(this Measurement measurement, IterationMode mode, IterationStage stage)
 => measurement.IterationMode == mode && measurement.IterationStage == stage;
Beispiel #4
0
 [PublicAPI] public static bool IsOverhead(this Measurement measurement) => measurement.IterationMode == IterationMode.Overhead;
Beispiel #5
0
 //TODO OPTIONAL ENCODING
 public static string ToStr(this Measurement run, Encoding encoding) =>
 $"{run.IterationMode}{run.IterationStage} {run.IterationIndex}: {run.Operations} op, {run.Nanoseconds.ToStr()} ns, {run.GetAverageNanoseconds().ToTimeStr(encoding ?? Encoding.ASCII)}/op";
Beispiel #6
0
 /// <summary>
 /// Gets the average duration of one operation in nanoseconds.
 /// </summary>
 public static double GetAverageNanoseconds(this Measurement report) =>
 report.Nanoseconds / report.Operations;
Beispiel #7
0
 /// <summary>
 /// Gets the number of operations performed per second (ops/sec).
 /// </summary>
 public static double GetOpsPerSecond(this Measurement report) =>
 report.Operations / (report.Nanoseconds / NanosecondsInSecond);
        public Measurement RunIteration(IterationData data)
        {
            // Initialization
            long invokeCount = data.InvokeCount;
            int unrollFactor = data.UnrollFactor;
            long totalOperations = invokeCount * OperationsPerInvoke;
            var action = data.IterationMode.IsIdle() ? IdleAction : MainAction;

            GcCollect();

            // Measure
            var clock = Clock.Start();
            action(invokeCount / unrollFactor);
            var clockSpan = clock.Stop();

            GcCollect();

            // Results
            var measurement = new Measurement(0, data.IterationMode, data.Index, totalOperations, clockSpan.GetNanoseconds());
            if (!IsDiagnoserAttached) WriteLine(measurement.ToOutputLine());

            return measurement;
        }
Beispiel #9
0
 public static string ToStr(this Measurement run) =>
 $"{run.IterationMode} {run.IterationIndex}: {run.Operations} op, {run.Nanoseconds.ToStr()} ns, {run.GetAverageNanoseconds().ToTimeStr()}/op";