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;
 }
Exemple #2
0
 [PublicAPI] public static bool IsWorkload(this Measurement measurement) => measurement.IterationMode == IterationMode.Workload;
Exemple #3
0
 public static bool Is(this Measurement measurement, IterationMode mode, IterationStage stage)
 => measurement.IterationMode == mode && measurement.IterationStage == stage;
Exemple #4
0
 [PublicAPI] public static bool IsOverhead(this Measurement measurement) => measurement.IterationMode == IterationMode.Overhead;
Exemple #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";
Exemple #6
0
 /// <summary>
 /// Gets the average duration of one operation in nanoseconds.
 /// </summary>
 public static double GetAverageNanoseconds(this Measurement report) =>
 report.Nanoseconds / report.Operations;
Exemple #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;
        }
Exemple #9
0
 public static string ToStr(this Measurement run) =>
 $"{run.IterationMode} {run.IterationIndex}: {run.Operations} op, {run.Nanoseconds.ToStr()} ns, {run.GetAverageNanoseconds().ToTimeStr()}/op";