Ejemplo n.º 1
0
 public RunResults(
     [CanBeNull] IReadOnlyList <Measurement> idle, [NotNull] IReadOnlyList <Measurement> main, OutlierMode outlierMode, GcStats gcStats)
 {
     this.outlierMode = outlierMode;
     Idle             = idle;
     Main             = main;
     GCStats          = gcStats;
 }
Ejemplo n.º 2
0
 public RunResults(
     [CanBeNull] IReadOnlyList <Measurement> idle, [NotNull] IReadOnlyList <Measurement> main, bool removeOutliers, GcStats gcStats)
 {
     this.removeOutliers = removeOutliers;
     Idle    = idle;
     Main    = main;
     GCStats = gcStats;
 }
Ejemplo n.º 3
0
 public RunResults([CanBeNull] IReadOnlyList <Measurement> overhead,
                   [NotNull] IReadOnlyList <Measurement> workload,
                   OutlierMode outlierMode,
                   GcStats gcStats,
                   Encoding encoding)
 {
     this.outlierMode = outlierMode;
     this.encoding    = encoding;
     Overhead         = overhead;
     Workload         = workload;
     GCStats          = gcStats;
 }
Ejemplo n.º 4
0
 public RunResults([CanBeNull] IReadOnlyList <Measurement> overhead,
                   [NotNull] IReadOnlyList <Measurement> workload,
                   OutlierMode outlierMode,
                   GcStats gcStats,
                   ThreadingStats threadingStats)
 {
     this.outlierMode = outlierMode;
     Overhead         = overhead;
     Workload         = workload;
     GCStats          = gcStats;
     ThreadingStats   = threadingStats;
 }
Ejemplo n.º 5
0
        public RunResults Run()
        {
            if (Strategy.NeedsJitting() != isJitted)
            {
                throw new Exception($"You must{(Strategy.NeedsJitting() ? "" : " not")} call Jitting() first (Strategy = {Strategy})!");
            }
            if (!isPreAllocated)
            {
                throw new Exception("You must call PreAllocate() first!");
            }

            long invokeCount = InvocationCount;
            IReadOnlyList <Measurement> idle = null;

            if (Strategy != RunStrategy.ColdStart)
            {
                if (Strategy != RunStrategy.Monitoring)
                {
                    invokeCount = pilotStage.Run();

                    if (EvaluateOverhead)
                    {
                        warmupStage.RunIdle(invokeCount, UnrollFactor);
                        idle = targetStage.RunIdle(invokeCount, UnrollFactor);
                    }
                }

                warmupStage.RunMain(invokeCount, UnrollFactor, forceSpecific: Strategy == RunStrategy.Monitoring);
            }

            // we enable monitoring after pilot & warmup, just to ignore the memory allocated by these runs
            EnableMonitoring();
            if (IsDiagnoserAttached)
            {
                Host.BeforeMainRun();
            }
            forcedFullGarbageCollections = 0; // zero it in case the Engine instance is reused (InProcessToolchain)
            var initialGcStats = GcStats.ReadInitial(IsDiagnoserAttached);

            var main = targetStage.RunMain(invokeCount, UnrollFactor, forceSpecific: Strategy == RunStrategy.Monitoring);

            var finalGcStats      = GcStats.ReadFinal(IsDiagnoserAttached);
            var forcedCollections = GcStats.FromForced(forcedFullGarbageCollections);
            var workGcHasDone     = finalGcStats - forcedCollections - initialGcStats;

            bool removeOutliers = TargetJob.ResolveValue(AccuracyMode.RemoveOutliersCharacteristic, Resolver);

            return(new RunResults(idle, main, removeOutliers, workGcHasDone));
        }
Ejemplo n.º 6
0
        public RunResults(
            [CanBeNull] IReadOnlyList <Measurement> idle, [NotNull] IReadOnlyList <Measurement> main, bool removeOutliers, GcStats gcStats)
        {
            this.removeOutliers = removeOutliers;
            Idle    = idle;
            Main    = main;
            GCStats = gcStats;

            totalOperationsCount = 0;
            foreach (var measurement in Main)
            {
                if (!measurement.IterationMode.IsIdle())
                {
                    totalOperationsCount += measurement.Operations;
                }
            }
        }
Ejemplo n.º 7
0
        private GcStats MeasureGcStats(IterationData data)
        {
            // we enable monitoring after main target run, for this single iteration which is executed at the end
            // so even if we enable AppDomain monitoring in separate process
            // it does not matter, because we have already obtained the results!
            EnableMonitoring();

            IterationSetupAction(); // we run iteration setup first, so even if it allocates, it is not included in the results

            var initialGcStats = GcStats.ReadInitial();

            MainAction(data.InvokeCount / data.UnrollFactor);

            var finalGcStats = GcStats.ReadFinal();

            IterationCleanupAction(); // we run iteration cleanup after collecting GC stats

            return((finalGcStats - initialGcStats).WithTotalOperations(data.InvokeCount * OperationsPerInvoke));
        }
Ejemplo n.º 8
0
        public RunResults Run()
        {
            if (!isJitted || !isPreAllocated)
            {
                throw new Exception("You must call PreAllocate() and Jitting() first!");
            }

            long invokeCount = InvocationCount;
            IReadOnlyList <Measurement> idle = null;

            if (Strategy != RunStrategy.ColdStart)
            {
                invokeCount = pilotStage.Run();

                if (EvaluateOverhead)
                {
                    warmupStage.RunIdle(invokeCount, UnrollFactor);
                    idle = targetStage.RunIdle(invokeCount, UnrollFactor);
                }

                warmupStage.RunMain(invokeCount, UnrollFactor);
            }

            // we enable monitoring after pilot & warmup, just to ignore the memory allocated by these runs
            EnableMonitoring();
            var initialGcStats = GcStats.ReadInitial(IsDiagnoserAttached);

            var main = targetStage.RunMain(invokeCount, UnrollFactor);

            var finalGcStats      = GcStats.ReadFinal(IsDiagnoserAttached);
            var forcedCollections = GcStats.FromForced(forcedFullGarbageCollections);
            var workGcHasDone     = finalGcStats - forcedCollections - initialGcStats;

            bool removeOutliers = TargetJob.ResolveValue(AccuracyMode.RemoveOutliersCharacteristic, Resolver);

            return(new RunResults(idle, main, removeOutliers, workGcHasDone));
        }