Пример #1
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);
        }
Пример #2
0
 /// <summary>Override competition loggers.</summary>
 /// <param name="competitionConfig">The competition config.</param>
 /// <returns>The loggers for the competition</returns>
 protected virtual List <ILogger> OverrideLoggers([NotNull] ICompetitionConfig competitionConfig) =>
 competitionConfig.GetLoggers().ToList();