本文整理汇总了C#中ILogger.WriteLineError方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.WriteLineError方法的具体用法?C# ILogger.WriteLineError怎么用?C# ILogger.WriteLineError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.WriteLineError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportToLog
public override void ExportToLog(Summary summary, ILogger logger)
{
logger.WriteLine("....");
foreach (var infoLine in HostEnvironmentInfo.GetCurrent().ToFormattedString())
{
logger.WriteLineInfo(infoLine);
}
logger.WriteLineInfo(summary.JobRuntimes);
logger.WriteLine();
PrintTable(summary.Table, logger);
var benchmarksWithTroubles = summary.Reports
.Where(r => !r.GetResultRuns().Any())
.Select(r => r.Benchmark)
.ToList();
if (benchmarksWithTroubles.Count > 0)
{
logger.WriteLine();
logger.WriteLine("[WARNING]");
logger.WriteLineError(".Benchmarks with issues");
logger.WriteLine("====");
foreach (var benchmarkWithTroubles in benchmarksWithTroubles)
logger.WriteLineError("* " + benchmarkWithTroubles.DisplayInfo);
logger.WriteLine("====");
}
}
示例2: IsSupported
public override bool IsSupported(Benchmark benchmark, ILogger logger)
{
if (benchmark.Job.Platform == Platform.X86)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only X64 compilation, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.Jit == Jit.LegacyJit)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only RyuJit, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
return true;
}
示例3: PrintTable
private void PrintTable(SummaryTable table, ILogger logger)
{
if (table.FullContent.Length == 0)
{
logger.WriteLineError("There are no benchmarks found ");
logger.NewLine();
return;
}
table.PrintCommonColumns(logger);
logger.NewLine();
if (useCodeBlocks)
{
logger.Write("```");
logger.NewLine();
}
table.PrintLine(table.FullHeader, logger, "", " |");
logger.NewLine();
logger.WriteLineStatistic(string.Join("", table.Columns.Where(c => c.NeedToShow).Select(c => new string('-', c.Width) + " |")));
foreach (var line in table.FullContent)
{
table.PrintLine(line, logger, "", " |");
logger.NewLine();
}
}
示例4: PrintTable
private void PrintTable(SummaryTable table, ILogger logger)
{
if (table.FullContent.Length == 0)
{
logger.WriteLineError("<pre>There are no benchmarks found</pre>");
return;
}
logger.Write("<pre><code>");
table.PrintCommonColumns(logger);
logger.WriteLine("</code></pre>");
logger.WriteLine();
logger.WriteLine("<table>");
logger.Write("<tr>");
table.PrintLine(table.FullHeader, logger, "<th>", "</th>");
logger.Write("</tr>");
foreach (var line in table.FullContent)
{
logger.Write("<tr>");
table.PrintLine(line, logger, "<td>", "</td>");
logger.Write("</tr>");
}
logger.WriteLine("</table>");
}
示例5: IsSupported
public override bool IsSupported(Benchmark benchmark, ILogger logger)
{
if (!EnvironmentInfo.GetCurrent().IsDotNetCliInstalled())
{
logger.WriteLineError($"BenchmarkDotNet requires dotnet cli toolchain to be installed, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
return true;
}
示例6: EnsureHighPriority
public static void EnsureHighPriority(this Process process, ILogger logger)
{
try
{
process.PriorityClass = ProcessPriorityClass.High;
}
catch (Exception ex)
{
logger.WriteLineError($"Failed to set up high priority. Make sure you have the right permissions. Message: {ex.Message}");
}
}
示例7: IsSupported
public virtual bool IsSupported(Benchmark benchmark, ILogger logger)
{
var runtime = benchmark.Job.Runtime == Runtime.Host ? RuntimeInformation.GetCurrent() : benchmark.Job.Runtime;
if (runtime != Runtime.Mono && benchmark.Job.Jit == Jit.Llvm)
{
logger.WriteLineError($"Llvm is supported only for Mono, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
return true;
}
示例8: IsSupported
public override bool IsSupported(Benchmark benchmark, ILogger logger)
{
if (!EnvironmentInfo.GetCurrent().IsDotNetCliInstalled())
{
logger.WriteLineError($"BenchmarkDotNet requires dotnet cli toolchain to be installed, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.Platform == Platform.X86)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only X64 compilation, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.Jit == Jit.LegacyJit)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only RyuJit, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
return true;
}
示例9: IsSupported
public virtual bool IsSupported(Benchmark benchmark, ILogger logger, IResolver resolver)
{
var runtime = benchmark.Job.ResolveValue(EnvMode.RuntimeCharacteristic, resolver);
var jit = benchmark.Job.ResolveValue(EnvMode.JitCharacteristic, resolver);
if (runtime != Runtime.Mono && jit == Jit.Llvm)
{
logger.WriteLineError($"Llvm is supported only for Mono, benchmark '{benchmark.DisplayInfo}' will not be executed");
return false;
}
return true;
}
示例10: IsSupported
public override bool IsSupported(Benchmark benchmark, ILogger logger, IResolver resolver)
{
if(!base.IsSupported(benchmark, logger, resolver))
{
return false;
}
if (!HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled())
{
logger.WriteLineError($"BenchmarkDotNet requires dotnet cli toolchain to be installed, benchmark '{benchmark.DisplayInfo}' will not be executed");
return false;
}
if (benchmark.Job.ResolveValue(EnvMode.PlatformCharacteristic, resolver) == Platform.X86)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only X64 compilation, benchmark '{benchmark.DisplayInfo}' will not be executed");
return false;
}
if (benchmark.Job.ResolveValue(EnvMode.JitCharacteristic, resolver) == Jit.LegacyJit)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only RyuJit, benchmark '{benchmark.DisplayInfo}' will not be executed");
return false;
}
if (benchmark.Job.ResolveValue(GcMode.CpuGroupsCharacteristic, resolver))
{
logger.WriteLineError($"Currently project.json does not support CpuGroups (app.config does), benchmark '{benchmark.DisplayInfo}' will not be executed");
return false;
}
if (benchmark.Job.ResolveValue(GcMode.AllowVeryLargeObjectsCharacteristic, resolver))
{
logger.WriteLineError($"Currently project.json does not support gcAllowVeryLargeObjects (app.config does), benchmark '{benchmark.DisplayInfo}' will not be executed");
return false;
}
return true;
}
示例11: IsSupported
public override bool IsSupported(Benchmark benchmark, ILogger logger)
{
if(!base.IsSupported(benchmark, logger))
{
return false;
}
if (!HostEnvironmentInfo.GetCurrent().IsDotNetCliInstalled())
{
logger.WriteLineError($"BenchmarkDotNet requires dotnet cli toolchain to be installed, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.Platform == Platform.X86)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only X64 compilation, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.Jit == Jit.LegacyJit)
{
logger.WriteLineError($"Currently dotnet cli toolchain supports only RyuJit, benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.GarbageCollection.CpuGroups)
{
logger.WriteLineError($"Currently project.json does not support CpuGroups (app.config does), benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
if (benchmark.Job.GarbageCollection.AllowVeryLargeObjects)
{
logger.WriteLineError($"Currently project.json does not support gcAllowVeryLargeObjects (app.config does), benchmark {benchmark.ShortInfo} will not be executed");
return false;
}
return true;
}
示例12: PrintTable
private static void PrintTable(SummaryTable table, ILogger logger)
{
if (table.FullContent.Length == 0)
{
logger.WriteLine("[WARNING]");
logger.WriteLine("====");
logger.WriteLineError("There are no benchmarks found ");
logger.WriteLine("====");
logger.WriteLine();
return;
}
table.PrintCommonColumns(logger);
logger.WriteLine("....");
logger.WriteLine("[options=\"header\"]");
logger.WriteLine("|===");
table.PrintLine(table.FullHeader, logger, "|", string.Empty);
foreach (var line in table.FullContent)
table.PrintLine(line, logger, "|", string.Empty);
logger.WriteLine("|===");
}
示例13: ExportToLog
public override void ExportToLog(Summary summary, ILogger logger)
{
if (useCodeBlocks)
logger.WriteLine($"```{codeBlocksSyntax}");
logger = GetRightLogger(logger);
logger.WriteLine();
foreach (var infoLine in HostEnvironmentInfo.GetCurrent().ToFormattedString())
{
logger.WriteLineInfo(infoLine);
}
logger.WriteLine();
PrintTable(summary.Table, logger);
// TODO: move this logic to an analyser
var benchmarksWithTroubles = summary.Reports.Where(r => !r.GetResultRuns().Any()).Select(r => r.Benchmark).ToList();
if (benchmarksWithTroubles.Count > 0)
{
logger.WriteLine();
logger.WriteLineError("Benchmarks with issues:");
foreach (var benchmarkWithTroubles in benchmarksWithTroubles)
logger.WriteLineError(" " + benchmarkWithTroubles.ShortInfo);
}
}
示例14: CopyFile
private void CopyFile(ILogger logger, string sourcePath, string destinationPath)
{
logger.WriteLineInfo("// Copying {0}", Path.GetFileName(sourcePath));
logger.WriteLineInfo("// from: {0}", Path.GetDirectoryName(sourcePath));
logger.WriteLineInfo("// to: {0}", Path.GetDirectoryName(destinationPath));
try
{
File.Copy(Path.GetFullPath(sourcePath), Path.GetFullPath(destinationPath), overwrite: true);
}
catch (Exception ex)
{
logger.WriteLineError(ex.Message);
throw;
}
}
示例15: Execute
private static List<ExecuteResult> Execute(ILogger logger, Benchmark benchmark, IToolchain toolchain, BuildResult buildResult, IConfig config, IResolver resolver)
{
var executeResults = new List<ExecuteResult>();
logger.WriteLineInfo("// *** Execute ***");
bool analyzeRunToRunVariance = benchmark.Job.ResolveValue(AccuracyMode.AnalyzeLaunchVarianceCharacteristic, resolver);
bool autoLaunchCount = !benchmark.Job.HasValue(RunMode.LaunchCountCharacteristic);
int defaultValue = analyzeRunToRunVariance ? 2 : 1;
int launchCount = Math.Max(
1,
autoLaunchCount ? defaultValue: benchmark.Job.Run.LaunchCount);
for (int launchIndex = 0; launchIndex < launchCount; launchIndex++)
{
string printedLaunchCount = (analyzeRunToRunVariance &&
autoLaunchCount &&
launchIndex < 2)
? ""
: " / " + launchCount;
logger.WriteLineInfo($"// Launch: {launchIndex + 1}{printedLaunchCount}");
var executeResult = toolchain.Executor.Execute(buildResult, benchmark, logger, resolver);
if (!executeResult.FoundExecutable)
logger.WriteLineError("Executable not found");
if (executeResult.ExitCode != 0)
logger.WriteLineError("ExitCode != 0");
executeResults.Add(executeResult);
var measurements = executeResults
.SelectMany(r => r.Data)
.Select(line => Measurement.Parse(logger, line, 0))
.Where(r => r.IterationMode != IterationMode.Unknown).
ToArray();
if (!measurements.Any())
{
// Something went wrong during the benchmark, don't bother doing more runs
logger.WriteLineError($"No more Benchmark runs will be launched as NO measurements were obtained from the previous run!");
break;
}
if (autoLaunchCount && launchIndex == 1 && analyzeRunToRunVariance)
{
// TODO: improve this logic
var idleApprox = new Statistics(measurements.Where(m => m.IterationMode == IterationMode.IdleTarget).Select(m => m.Nanoseconds)).Median;
var mainApprox = new Statistics(measurements.Where(m => m.IterationMode == IterationMode.MainTarget).Select(m => m.Nanoseconds)).Median;
var percent = idleApprox / mainApprox * 100;
launchCount = (int)Math.Round(Math.Max(2, 2 + (percent - 1) / 3)); // an empirical formula
}
}
logger.WriteLine();
// Do a "Diagnostic" run, but DISCARD the results, so that the overhead of Diagnostics doesn't skew the overall results
if (config.GetDiagnosers().Any())
{
logger.WriteLineInfo("// Run, Diagnostic");
var compositeDiagnoser = config.GetCompositeDiagnoser();
var executeResult = toolchain.Executor.Execute(buildResult, benchmark, logger, resolver, compositeDiagnoser);
var allRuns = executeResult.Data.Select(line => Measurement.Parse(logger, line, 0)).Where(r => r.IterationMode != IterationMode.Unknown).ToList();
var report = new BenchmarkReport(benchmark, null, null, new[] { executeResult }, allRuns);
compositeDiagnoser.ProcessResults(benchmark, report);
if (!executeResult.FoundExecutable)
logger.WriteLineError("Executable not found");
logger.WriteLine();
}
return executeResults;
}