Example #1
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));
        }
Example #2
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));
        }