protected static CompetitionTarget ParseCompetitionTarget( [NotNull] Target target, [NotNull] MetricInfo[] metrics, [CanBeNull] StoredTargetInfo storedTarget, [NotNull] IMessageLogger messageLogger) { if (storedTarget == null) { messageLogger.WriteInfoMessage( target, "Has no annotations applied, all metrics will be treated as empty.", "Check if the method was renamed; add annotations for the method or enable auto-annotation feature."); return(CreateEmptyCompetitionTarget(target, metrics)); } if (storedTarget.Baseline != null && storedTarget.Baseline != target.Baseline) { messageLogger.WriteSetupErrorMessage( target, "Baseline flag on the method and in the annotation do not match.", "Check if the method was renamed. Rename it back or update previous run log with new method name."); } var parseEvents = new List <(MetricInfo metric, MetricParseEvent parseEvent)>(); var result = ParseCompetitionMetricValues(target, metrics, storedTarget, parseEvents); ReportParseEventSummary(target, parseEvents, messageLogger); return(new CompetitionTarget(target, result.ToArray())); }
private static List <CompetitionMetricValue> ParseCompetitionMetricValues( Target target, MetricInfo[] metrics, StoredTargetInfo storedTarget, List <(MetricInfo, MetricParseEvent)> parseEvents)
protected static CompetitionTarget ParseCompetitionTarget( [NotNull] Target target, [NotNull] MetricInfo[] metrics, [CanBeNull] StoredTargetInfo storedTarget, [NotNull] IMessageLogger messageLogger) { var result = new List <CompetitionMetricValue>(); if (storedTarget == null) { messageLogger.WriteInfoMessage( target, "Has no annotations applied, all metrics will be threated as empty.", "Check if the method was renamed; add annnotations for the method or enable auto-annotation feature."); return(new CompetitionTarget(target, result.ToArray())); } if (storedTarget.Baseline != null && storedTarget.Baseline != target.Baseline) { messageLogger.WriteSetupErrorMessage( target, "Baseline flag on the method and in the annotation do not match.", "Check if the method was renamed. Rename it back or update previous run log with new method name."); } var hasAnyMetric = storedTarget.MetricValues.Any(); // TODO: group messages into one? var metricsByType = storedTarget.MetricValues.ToDictionary(m => m.MetricAttributeType); foreach (var metric in metrics) { var metricIsApplicable = !target.Baseline || !metric.IsRelative; if (metricsByType.TryGetValue(metric.AttributeType, out var storedMetric)) { if (metricIsApplicable) { var metricValue = storedMetric.ToMetricValue(metric); if (CheckMetricValue(target, metricValue, messageLogger)) { result.Add(storedMetric.ToMetricValue(metric)); } } else if (!metric.IsPrimaryMetric) { messageLogger.WriteSetupErrorMessage( target, $"Annotation for relative metric {metric} cannot be applied as the target is baseline.", "Check if baseline method for the competition was changed."); } } else if (metricIsApplicable) { if (hasAnyMetric) { messageLogger.WriteInfoMessage( target, $"Annotation for metric {metric} not found, threated as empty.", "Add annnotation for the metric or enable auto-annotation feature."); } result.Add(new CompetitionMetricValue(metric)); } } return(new CompetitionTarget(target, result.ToArray())); }