From ea2e818f126ae57fa1e851ccc09b3f35e40546f3 Mon Sep 17 00:00:00 2001 From: marc90 Date: Fri, 2 Aug 2019 19:15:29 +0300 Subject: [PATCH] Log shows a wrong name for plot images #1181 https://github.com/dotnet/BenchmarkDotNet/issues/1181 --- src/BenchmarkDotNet/Exporters/RPlotExporter.cs | 8 +++----- src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs | 8 ++++++++ src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/BenchmarkDotNet/Exporters/RPlotExporter.cs b/src/BenchmarkDotNet/Exporters/RPlotExporter.cs index 11fef179e2..afc8a5f159 100644 --- a/src/BenchmarkDotNet/Exporters/RPlotExporter.cs +++ b/src/BenchmarkDotNet/Exporters/RPlotExporter.cs @@ -16,6 +16,7 @@ public class RPlotExporter : IExporter, IExporterDependencies public static readonly IExporter Default = new RPlotExporter(); public string Name => nameof(RPlotExporter); + private const string ImageExtension = ".png"; private static readonly object BuildScriptLock = new object(); public IEnumerable Dependencies @@ -30,9 +31,7 @@ public IEnumerable ExportToFiles(Summary summary, ILogger consoleLogger) const string logFileName = "BuildPlots.log"; yield return scriptFileName; - string fileNamePrefix = Path.Combine(summary.ResultsDirectoryPath, summary.Title); string csvFullPath = CsvMeasurementsExporter.Default.GetArtifactFullName(summary); - string scriptFullPath = Path.Combine(summary.ResultsDirectoryPath, scriptFileName); string logFullPath = Path.Combine(summary.ResultsDirectoryPath, logFileName); string script = ResourceHelper. @@ -65,8 +64,7 @@ public IEnumerable ExportToFiles(Summary summary, ILogger consoleLogger) process?.WaitForExit(); } - yield return fileNamePrefix + "-boxplot.png"; - yield return fileNamePrefix + "-barplot.png"; + yield return $"*{ImageExtension}"; } public void ExportToLog(Summary summary, ILogger logger) @@ -125,4 +123,4 @@ private static string FindInPath(string fileName) return null; } } -} \ No newline at end of file +} diff --git a/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs b/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs index 7a25c04c38..8f25182eb7 100644 --- a/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs +++ b/src/BenchmarkDotNet/Extensions/StringAndTextExtensions.cs @@ -84,5 +84,13 @@ internal static string HtmlEncode(this string s) } return sb.ToString(); } + + /// + /// Returns file base name + /// + internal static string GetBaseName(this string path, string directory) + { + return path.Replace(directory, string.Empty).Trim('/', '\\'); + } } } diff --git a/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs b/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs index 81fbea849a..bcca3f6ab1 100644 --- a/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs +++ b/src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs @@ -28,7 +28,7 @@ namespace BenchmarkDotNet.Running internal static class BenchmarkRunnerClean { internal const string DateTimeFormat = "yyyyMMdd-HHmmss"; - + internal static readonly IResolver DefaultResolver = new CompositeResolver(EnvironmentResolver.Instance, InfrastructureResolver.Instance); internal static Summary[] Run(BenchmarkRunInfo[] benchmarkRunInfos) @@ -196,7 +196,7 @@ private static void PrintSummary(ILogger logger, ImmutableConfig config, Summary string currentDirectory = Directory.GetCurrentDirectory(); foreach (string file in config.GetCompositeExporter().ExportToFiles(summary, logger)) { - logger.WriteLineInfo($" {file.Replace(currentDirectory, string.Empty).Trim('/', '\\')}"); + logger.WriteLineInfo($" {file.GetBaseName(currentDirectory)}"); } logger.WriteLine();