private static string GetDisassemblerPath(string architectureName) { // one can only attach to a process of same target architecture, this is why we need exe for x64 and for x86 string exeName = $"BenchmarkDotNet.Disassembler.{architectureName}.exe"; var assemblyWithDisassemblersInResources = typeof(WindowsDisassembler).GetTypeInfo().Assembly; var dir = new FileInfo(assemblyWithDisassemblersInResources.Location).Directory ?? throw new DirectoryNotFoundException(); string disassemblerPath = Path.Combine( dir.FullName, FolderNameHelper.ToFolderName(BenchmarkDotNetInfo.FullVersion), // possible update exeName); // separate process per architecture!! Path.GetDirectoryName(disassemblerPath).CreateIfNotExists(); #if !PRERELEASE_DEVELOP // for development we always want to copy the file to not omit any dev changes (Properties.BenchmarkDotNetInfo.FullVersion in file name is not enough) if (File.Exists(disassemblerPath)) { return(disassemblerPath); } #endif // the disassembler has not been yet retrieved from the resources CopyFromResources( assemblyWithDisassemblersInResources, $"BenchmarkDotNet.Disassemblers.net461.win7_{architectureName}.{exeName}", disassemblerPath); CopyAllRequiredDependencies(assemblyWithDisassemblersInResources, Path.GetDirectoryName(disassemblerPath)); return(disassemblerPath); }
private static string GetFileName(Summary summary) { // few types might have the same name: A.Name and B.Name will both report "Name" // in that case, we can not use the type name as file name because they would be getting overwritten #529 var typeNames = summary.Benchmarks.Select(b => b.Target.Type).Distinct().GroupBy(type => type.Name); if (typeNames.Count() == 1 && typeNames.First().Count() == 1) { return(FolderNameHelper.ToFolderName(summary.Benchmarks.Select(b => b.Target.Type).First())); } return(summary.Title); }
private static string GetFileName(Summary summary) { // we can't use simple name here, because user might be running benchmarks for a library, which defines few types with the same name // and reports the results per type, so every summary is going to contain just single benchmark // and we can't tell here if there is a name conflict or not var targets = summary.Benchmarks.Select(b => b.Target.Type).Distinct().ToArray(); if (targets.Length == 1) { return(FolderNameHelper.ToFolderName(targets.Single())); } return(summary.Title); }
private static string GetTitle(IList <Benchmark> benchmarks) { // few types might have the same name: A.Name and B.Name will both report "Name" // in that case, we can not use the type name as file name because they would be getting overwritten #529 var typeNames = benchmarks.Select(b => b.Target.Type).Distinct().GroupBy(type => type.Name); if (typeNames.Count() == 1 && typeNames.Single().Count() == 1) { return(FolderNameHelper.ToFolderName(benchmarks.Select(b => b.Target.Type).First())); } benchmarkRunIndex++; return($"BenchmarkRun-{benchmarkRunIndex:##000}-{DateTime.Now:yyyy-MM-dd-hh-mm-ss}"); }
public static string GetFileName(Summary summary) { if (summary is null) { throw new ArgumentNullException(nameof(summary)); } var targets = summary.BenchmarksCases.Select(b => b.Descriptor.Type).Distinct().ToArray(); if (targets.Length == 1) return FolderNameHelper.ToFolderName(targets.Single()); return summary.Title; }
private static string GetTitle(BenchmarkRunInfo[] benchmarkRunInfos) { // few types might have the same name: A.Name and B.Name will both report "Name" // in that case, we can not use the type name as file name because they would be getting overwritten #529 var uniqueTargetTypes = benchmarkRunInfos.SelectMany(info => info.Benchmarks.Select(benchmark => benchmark.Target.Type)).Distinct().ToArray(); if (uniqueTargetTypes.Length == 1) { return(FolderNameHelper.ToFolderName(uniqueTargetTypes[0])); } benchmarkRunIndex++; return($"BenchmarkRun-{benchmarkRunIndex:##000}-{DateTime.Now:yyyy-MM-dd-hh-mm-ss}"); }
private string GetFilePath(DiagnoserActionParameters details, DateTime creationTime) { string fileName = $@"{FolderNameHelper.ToFolderName(details.BenchmarkCase.Descriptor.Type)}.{FullNameProvider.GetMethodName(details.BenchmarkCase)}"; // if we run for more than one toolchain, the output file name should contain the name too so we can differ net461 vs netcoreapp2.1 etc if (details.Config.GetJobs().Select(job => job.GetToolchain()).Distinct().Count() > 1) { fileName += $"-{details.BenchmarkCase.Job.Environment.Runtime?.Name ?? details.BenchmarkCase.GetToolchain()?.Name ?? details.BenchmarkCase.Job.Id}"; } fileName += $"-{creationTime.ToString(BenchmarkRunnerClean.DateTimeFormat)}"; fileName = FolderNameHelper.ToFolderName(fileName); return(Path.Combine(details.Config.ArtifactsPath, $"{fileName}{FileExtension}")); }
private string Export(Summary summary, BenchmarkCase benchmarkCase, DisassemblyResult disassemblyResult, PmcStats pmcStats) { string filePath = Path.Combine(summary.ResultsDirectoryPath, $"{FolderNameHelper.ToFolderName(benchmarkCase.Descriptor.Type)}." + $"{benchmarkCase.Descriptor.WorkloadMethod.Name}." + $"{GetShortRuntimeInfo(summary[benchmarkCase].GetRuntimeInfo())}.counters.html"); filePath.DeleteFileIfExists(); var totals = SumHardwareCountersStatsOfBenchmarkedCode(disassemblyResult, pmcStats); var perMethod = SumHardwareCountersPerMethod(disassemblyResult, pmcStats); using (var stream = new StreamWriter(filePath, append: false)) { using (var streamLogger = new StreamLogger(stream)) { Export(streamLogger, benchmarkCase, totals, perMethod, pmcStats.Counters.Keys.ToArray()); } } return(filePath); }
public void FolderNameTest() { string directoryPath = @"c:\test"; List <string> folderNames = new List <string>(); List <string> certificateName = new List <string> { "contoso.com", "www.contoso.com", "anytown.store.contoso.com.br", "*.contoso.com", "contoso.com,www.contoso.com", "contoso.com,*.contoso.com", }; foreach (string name in certificateName) { string folderName = FolderNameHelper.GetFolderPath(name, directoryPath); folderNames.Add(folderName); } Assert.AreEqual(1, 1); }
private string GetFilePath(DiagnoserActionParameters details, DateTime creationTime) { var folderPath = details.Config.ArtifactsPath; folderPath = Path.Combine(folderPath, $"{creationTime:yyyyMMdd-hhmm}-{Process.GetCurrentProcess().Id}"); // if we run for more than one toolchain, the output file name should contain the name too so we can differ net461 vs netcoreapp2.1 etc if (details.Config.GetJobs().Select(job => job.Infrastructure.Toolchain).Distinct().Count() > 1) { folderPath = Path.Combine(folderPath, details.BenchmarkCase.Job.Infrastructure.Toolchain.Name); } if (!string.IsNullOrWhiteSpace(details.BenchmarkCase.Descriptor.Type.Namespace)) { folderPath = Path.Combine(folderPath, details.BenchmarkCase.Descriptor.Type.Namespace.Replace('.', Path.DirectorySeparatorChar)); } folderPath = Path.Combine(folderPath, FolderNameHelper.ToFolderName(details.BenchmarkCase.Descriptor.Type, includeNamespace: false)); var fileName = FolderNameHelper.ToFolderName(FullNameProvider.GetMethodName(details.BenchmarkCase)); return(Path.Combine(folderPath, $"{fileName}{FileExtension}")); }
public void FileNamesAreConsistentAcrossOSes(object value, string expectedName) { Assert.Equal(expectedName, FolderNameHelper.ToFolderName(value)); }
public void ToFolderNameStructTest() { Assert.Equal("0-42", FolderNameHelper.ToFolderName(0.42m)); Assert.Equal("1234000000ns", FolderNameHelper.ToFolderName(TimeInterval.FromSeconds(1.234))); }
public override string ToPresentation(ICharacteristic characteristic) { return(characteristic.IsDefault ? "Default" : FolderNameHelper.ToFolderName(characteristic.ObjectValue)); }
public override string ToPresentation(object characteristicValue, Characteristic characteristic) => FolderNameHelper.ToFolderName(characteristicValue);
public override string ToPresentation(CharacteristicObject obj, Characteristic characteristic) { return(obj.HasValue(characteristic) ? FolderNameHelper.ToFolderName(characteristic[obj]) : "Default"); }
public override string ToPresentation(JobMode jobMode, Characteristic characteristic) { return(jobMode.HasValue(characteristic) ? FolderNameHelper.ToFolderName(characteristic[jobMode]) : "Default"); }
public void ToFolderNameTest(object value, string expectedName) { Assert.Equal(expectedName, FolderNameHelper.ToFolderName(value)); }