Esempio n. 1
0
        /// <summary>Init the competition state.</summary>
        /// <param name="benchmarkType">Type of the benchmark.</param>
        /// <param name="competitionConfig">The config for the competition.</param>
        internal void FirstTimeInit(
            [NotNull] Type benchmarkType,
            [NotNull] ICompetitionConfig competitionConfig)
        {
            Code.NotNull(benchmarkType, nameof(benchmarkType));
            Code.NotNull(competitionConfig, nameof(competitionConfig));

            lock (_lockKey)
            {
                AsserIsInInit();

                _stopwatch.Restart();

                BenchmarkType = benchmarkType;
                Config        = competitionConfig;
                Logger        = competitionConfig.GetCompositeLogger();

                RunNumber = 0;
                RunsLeft  = 1;

                HighestMessageSeverityInRun = MessageSeverity.Verbose;
                HighestMessageSeverity      = MessageSeverity.Verbose;
                MessagesInRun  = 0;
                LastRunSummary = null;

                Completed = false;
                _summaries.Clear();
                _messages.Clear();
            }
        }
        /// <summary>Initializes a new instance of the <see cref="CompetitionState"/> class.</summary>
        internal CompetitionState(
            [NotNull] Type benchmarkType,
            [NotNull] ICompetitionConfig competitionConfig)
        {
            Code.NotNull(benchmarkType, nameof(benchmarkType));
            Code.NotNull(competitionConfig, nameof(competitionConfig));

            SummaryFromAllRuns = _summaries.AsReadOnly();

            BenchmarkType = benchmarkType;
            Config        = competitionConfig;
            Logger        = competitionConfig.GetCompositeLogger();

            RunNumber = 0;
            RunsLeft  = 1;

            HighestMessageSeverityInRun = MessageSeverity.Verbose;
            HighestMessageSeverity      = MessageSeverity.Verbose;
            LastRunSummary = null;
        }