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.ExcludeAllocationQuantumSideEffects())); }
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)); }
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)); }