示例#1
0
        private CompetitionState RunCore(
            [NotNull] Type benchmarkType,
            [CanBeNull] ICompetitionConfig competitionConfig)
        {
            Code.NotNull(benchmarkType, nameof(benchmarkType));

            competitionConfig = PrepareCompetitionConfig(benchmarkType, competitionConfig);
            var benchmarkConfig = CreateBenchmarkConfig(competitionConfig);
            var hostLogger      = benchmarkConfig.GetLoggers().OfType <HostLogger>().Single();

            var previousDirectory = Environment.CurrentDirectory;
            var currentDirectory  = GetOutputDirectory(benchmarkType.Assembly);

            if (currentDirectory == previousDirectory)
            {
                currentDirectory  = null;
                previousDirectory = null;
            }

            CompetitionState competitionState = null;

            try
            {
                SetCurrentDirectoryIfNotNull(currentDirectory);
                try
                {
                    competitionState = CompetitionCore.Run(
                        benchmarkType, benchmarkConfig,
                        competitionConfig.MaxRunsAllowed,
                        competitionConfig.AllowDebugBuilds,
                        competitionConfig.ConcurrentRunBehavior);

                    ProcessRunComplete(competitionConfig, competitionState);
                }
                finally
                {
                    ReportHostLogger(hostLogger, competitionState?.LastRunSummary);
                }

                using (Loggers.HostLogger.BeginLogImportant(benchmarkConfig))
                {
                    ReportMessagesToUser(competitionConfig, competitionState);
                }
            }
            finally
            {
                Loggers.HostLogger.FlushLoggers(benchmarkConfig);
                SetCurrentDirectoryIfNotNull(previousDirectory);
            }

            return(competitionState);
        }
示例#2
0
        private CompetitionState RunCore(
            [NotNull] Type benchmarkType,
            [CanBeNull] ICompetitionConfig competitionConfig,
            [CanBeNull] CompetitionFeatures competitionFeatures)
        {
            Code.NotNull(benchmarkType, nameof(benchmarkType));

            competitionConfig = CreateBenchmarkConfig(benchmarkType, competitionConfig, competitionFeatures);

            var hostLogger = competitionConfig.GetLoggers().OfType <HostLogger>().Single();

            var previousDirectory = Environment.CurrentDirectory;
            var currentDirectory  = GetOutputDirectory(benchmarkType.Assembly);

            if (currentDirectory == previousDirectory)
            {
                currentDirectory  = null;
                previousDirectory = null;
            }

            CompetitionState competitionState = null;

            try
            {
                SetCurrentDirectoryIfNotNull(currentDirectory);
                try
                {
                    competitionState = CompetitionCore.Run(benchmarkType, competitionConfig);

                    ProcessRunComplete(competitionState);
                }
                finally
                {
                    ReportHostLogger(hostLogger, competitionState?.LastRunSummary);
                }

                using (FilteringLogger.BeginLogImportant(competitionState.Config))
                {
                    ReportMessagesToUser(competitionState);
                }
            }
            finally
            {
                LoggerHelpers.FlushLoggers(competitionConfig);
                SetCurrentDirectoryIfNotNull(previousDirectory);
            }

            return(competitionState);
        }
示例#3
0
 // TODO: HACK: Remove after update to BDN 10.4
 /// <summary>Runs the competition - core implementation.</summary>
 /// <param name="benchmarkType">Benchmark class to run.</param>
 /// <param name="competitionConfig">The competition config.</param>
 /// <returns>Competition state for the run.</returns>
 protected virtual CompetitionState RunCore(Type benchmarkType, ICompetitionConfig competitionConfig) =>
 CompetitionCore.Run(benchmarkType, competitionConfig);