Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve appearance of validation output #2179

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)
{
var compositeLogger = CreateCompositeLogger(benchmarkRunInfos, streamLogger);

compositeLogger.WriteLineInfo("// Validating benchmarks:");
compositeLogger.WriteLineHeader("// ***** Validating benchmarks *****");

var (supportedBenchmarks, validationErrors) = GetSupportedBenchmarks(benchmarkRunInfos, resolver);

Expand All @@ -68,7 +68,7 @@ internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos)

int totalBenchmarkCount = supportedBenchmarks.Sum(benchmarkInfo => benchmarkInfo.BenchmarksCases.Length);
int benchmarksToRunCount = totalBenchmarkCount - (idToResume + 1); // ids are indexed from 0
compositeLogger.WriteLineHeader("// ***** BenchmarkRunner: Start *****");
compositeLogger.WriteLineHeader("// ***** BenchmarkRunner: Start *****");
compositeLogger.WriteLineHeader($"// ***** Found {totalBenchmarkCount} benchmark(s) in total *****");
var globalChronometer = Chronometer.Start();

Expand Down Expand Up @@ -267,7 +267,7 @@ private static void PrintSummary(ILogger logger, ImmutableConfig config, Summary
{
var cultureInfo = config.CultureInfo ?? DefaultCultureInfo.Instance;

logger.WriteLineHeader("// ***** BenchmarkRunner: Finish *****");
logger.WriteLineHeader("// ***** BenchmarkRunner: Finish *****");
logger.WriteLine();

logger.WriteLineHeader("// * Export *");
Expand Down Expand Up @@ -352,7 +352,7 @@ private static ImmutableArray<ValidationError> Validate(params BenchmarkRunInfo[

private static Dictionary<BuildPartition, BuildResult> BuildInParallel(ILogger logger, string rootArtifactsFolderPath, BuildPartition[] buildPartitions, in StartedClock globalChronometer)
{
logger.WriteLineHeader($"// ***** Building {buildPartitions.Length} exe(s) in Parallel: Start *****");
logger.WriteLineHeader($"// ***** Building {buildPartitions.Length} exe(s) in Parallel: Start *****");

var buildLogger = buildPartitions.Length == 1 ? logger : NullLogger.Instance; // when we have just one partition we can print to std out

Expand All @@ -365,20 +365,20 @@ private static Dictionary<BuildPartition, BuildResult> BuildInParallel(ILogger l

var afterParallelBuild = globalChronometer.GetElapsed();

logger.WriteLineHeader($"// ***** Done, took {GetFormattedDifference(beforeParallelBuild, afterParallelBuild)} *****");
logger.WriteLineHeader($"// ***** Done, took {GetFormattedDifference(beforeParallelBuild, afterParallelBuild)} *****");

if (buildPartitions.Length <= 1 || !buildResults.Values.Any(result => result.IsGenerateSuccess && !result.IsBuildSuccess))
return buildResults;

logger.WriteLineHeader("// ***** Failed to build in Parallel, switching to sequential build *****");
logger.WriteLineHeader("// ***** Failed to build in Parallel, switching to sequential build *****");

foreach (var buildPartition in buildPartitions)
if (buildResults[buildPartition].IsGenerateSuccess && !buildResults[buildPartition].IsBuildSuccess && !buildResults[buildPartition].TryToExplainFailureReason(out string _))
buildResults[buildPartition] = Build(buildPartition, rootArtifactsFolderPath, buildLogger);

var afterSequentialBuild = globalChronometer.GetElapsed();

logger.WriteLineHeader($"// ***** Done, took {GetFormattedDifference(afterParallelBuild, afterSequentialBuild)} *****");
logger.WriteLineHeader($"// ***** Done, took {GetFormattedDifference(afterParallelBuild, afterSequentialBuild)} *****");

return buildResults;

Expand Down Expand Up @@ -692,7 +692,7 @@ private static void PrintValidationErrors(ILogger logger, IEnumerable<Validation
logger.WriteLineInfo($"// Benchmark {validationError.BenchmarkCase.DisplayInfo}");
}

logger.WriteLineError($"// * {validationError.Message}");
logger.WriteLineError(validationError.Message);
logger.WriteLine();
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/BenchmarkDotNet/Running/PowerManagementApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ private void ApplyUserPowerPlan()
{
powerPlanChanged = false;
var powerPlanFriendlyName = PowerManagementHelper.CurrentPlanFriendlyName;
logger.WriteLineInfo($"Successfully reverted power plan (GUID: {userCurrentPowerPlan.Value} FriendlyName: {powerPlanFriendlyName})");
logger.WriteLineInfo($"// Successfully reverted power plan (GUID: {userCurrentPowerPlan.Value} FriendlyName: {powerPlanFriendlyName})");
}
}
catch (Exception ex)
{
logger.WriteLineError($"Cannot revert power plan (error message: {ex.Message})");
logger.WriteLineError($"// Cannot revert power plan (error message: {ex.Message})");
}
}
}
Expand All @@ -76,15 +76,15 @@ private void ApplyPlanByGuid(Guid guid)
{
powerPlanChanged = true;
var powerPlanFriendlyName = PowerManagementHelper.CurrentPlanFriendlyName;
logger.WriteLineInfo($"Setup power plan (GUID: {guid} FriendlyName: {powerPlanFriendlyName})");
logger.WriteLineInfo($"// Setup power plan (GUID: {guid} FriendlyName: {powerPlanFriendlyName})");
}
else
logger.WriteLineError($"Cannot setup power plan (GUID: {guid})");
logger.WriteLineError($"// Cannot setup power plan (GUID: {guid})");
}
catch (Exception ex)
{
logger.WriteLineError($"Cannot setup power plan (GUID: {guid}, error message: {ex.Message})");
logger.WriteLineError($"// Cannot setup power plan (GUID: {guid}, error message: {ex.Message})");
}
}
}
}
}
14 changes: 7 additions & 7 deletions src/BenchmarkDotNet/Validators/JitOptimizationsValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ public IEnumerable<ValidationError> Validate(ValidationParameters validationPara
yield return new ValidationError(
TreatsWarningsAsErrors,
$"Assembly {group.Key.GetName().Name} which defines benchmarks references non-optimized {referencedAssemblyName.Name}" +
$"{Environment.NewLine}\tIf you own this dependency, please, build it in RELEASE." +
$"{Environment.NewLine}\tIf you don't, you can disable this policy by using 'config.WithOptions(ConfigOptions.DisableOptimizationsValidator)'.");
$"{Environment.NewLine} If you own this dependency, please, build it in RELEASE." +
$"{Environment.NewLine} If you don't, you can disable this policy by using 'config.WithOptions(ConfigOptions.DisableOptimizationsValidator)'.");
}
}

if (group.Key.IsJitOptimizationDisabled().IsTrue())
{
yield return new ValidationError(
TreatsWarningsAsErrors,
$"Assembly {group.Key.GetName().Name} which defines benchmarks is non-optimized" + Environment.NewLine +
"Benchmark was built without optimization enabled (most probably a DEBUG configuration). Please, build it in RELEASE." + Environment.NewLine +
"If you want to debug the benchmarks, please see https://benchmarkdotnet.org/articles/guides/troubleshooting.html#debugging-benchmarks."
$"Assembly {group.Key.GetName().Name} which defines benchmarks is non-optimized" +
$"{Environment.NewLine} Benchmark was built without optimization enabled (most probably a DEBUG configuration). Please, build it in RELEASE." +
$"{Environment.NewLine} If you want to debug the benchmarks, please see https://benchmarkdotnet.org/articles/guides/troubleshooting.html#debugging-benchmarks."
+ (group.Key.IsLinqPad()
? Environment.NewLine + "Please enable optimizations in your LINQPad. Go to Preferences -> Query and select \"compile with /optimize+\""
? $"{Environment.NewLine} Please enable optimizations in your LINQPad. Go to Preferences -> Query and select \"compile with /optimize+\""
: string.Empty));
}
}
}
}
}
}