public static void RunCore(IHost host, Benchmark benchmark, BenchmarkActionCodegen codegenMode) { var target = benchmark.Target; var job = benchmark.Job; // TODO: filter job (same as SourceCodePresenter does)? var unrollFactor = benchmark.Job.ResolveValue(RunMode.UnrollFactorCharacteristic, EnvResolver.Instance); // var dummyUnrollFactor = 1 << 6; // TODO: as arg to CreateDummy()? // DONTTOUCH: these should be allocated together var instance = Activator.CreateInstance(benchmark.Target.Type); var mainAction = BenchmarkActionFactory.CreateRun(target, instance, codegenMode, unrollFactor); var idleAction = BenchmarkActionFactory.CreateIdle(target, instance, codegenMode, unrollFactor); var setupAction = BenchmarkActionFactory.CreateSetup(target, instance); var cleanupAction = BenchmarkActionFactory.CreateCleanup(target, instance); var dummy1 = BenchmarkActionFactory.CreateDummy(); var dummy2 = BenchmarkActionFactory.CreateDummy(); var dummy3 = BenchmarkActionFactory.CreateDummy(); FillMembers(instance, benchmark); host.WriteLine(); foreach (var infoLine in BenchmarkEnvironmentInfo.GetCurrent().ToFormattedString()) { host.WriteLine("// {0}", infoLine); } host.WriteLine("// Job: {0}", job.DisplayInfo); host.WriteLine(); var engineParameters = new EngineParameters { Host = host, MainAction = mainAction.InvokeMultiple, Dummy1Action = dummy1.InvokeSingle, Dummy2Action = dummy2.InvokeSingle, Dummy3Action = dummy3.InvokeSingle, IdleAction = idleAction.InvokeMultiple, SetupAction = setupAction.InvokeSingle, CleanupAction = cleanupAction.InvokeSingle, TargetJob = job, OperationsPerInvoke = target.OperationsPerInvoke }; var engine = job .ResolveValue(InfrastructureMode.EngineFactoryCharacteristic, InfrastructureResolver.Instance) .Create(engineParameters); engine.PreAllocate(); setupAction.InvokeSingle(); if (job.ResolveValue(RunMode.RunStrategyCharacteristic, EngineResolver.Instance).NeedsJitting()) { engine.Jitting(); // does first call to main action, must be executed after setup()! } if (host.IsDiagnoserAttached) { host.AfterSetup(); } var results = engine.Run(); if (host.IsDiagnoserAttached) { host.BeforeCleanup(); } cleanupAction.InvokeSingle(); host.ReportResults(results); // printing costs memory, do this after runs }