- Added MaddoShared.Benchmarks project with BenchmarkDotNet for comprehensive image processing performance tests (parallel, chunk, size, stress). - Included helper for generating test images and custom configs to ensure InProcess toolchain for .NET Windows compatibility. - Added cross-platform scripts to run benchmarks easily. - Updated .gitignore for benchmark artifacts and temp files. - Exposed GetFilesToProcessPublic in ImageCreationStuff for testability. - Added file name sanitization in ImageCreatorSharp to prevent IO errors. - Enhanced WinForms UI: added "Open" buttons for source/destination folders, handled folder opening in Explorer, and improved user messaging and layout. - Updated solution file to include new benchmark project.
91 lines
3 KiB
C#
91 lines
3 KiB
C#
using BenchmarkDotNet.Columns;
|
|
using BenchmarkDotNet.Configs;
|
|
using BenchmarkDotNet.Diagnosers;
|
|
using BenchmarkDotNet.Engines;
|
|
using BenchmarkDotNet.Exporters;
|
|
using BenchmarkDotNet.Exporters.Csv;
|
|
using BenchmarkDotNet.Jobs;
|
|
using BenchmarkDotNet.Loggers;
|
|
using BenchmarkDotNet.Toolchains.InProcess.Emit;
|
|
|
|
namespace MaddoShared.Benchmarks;
|
|
|
|
/// <summary>
|
|
/// InProcess configuration for benchmarks requiring Windows-specific APIs
|
|
/// This avoids the net10.0-windows vs net10.0 compatibility issue
|
|
/// </summary>
|
|
public class InProcessConfig : ManualConfig
|
|
{
|
|
public InProcessConfig()
|
|
{
|
|
AddLogger(ConsoleLogger.Default);
|
|
AddExporter(HtmlExporter.Default);
|
|
AddExporter(MarkdownExporter.GitHub);
|
|
AddExporter(CsvExporter.Default);
|
|
AddDiagnoser(MemoryDiagnoser.Default);
|
|
|
|
// Add job with InProcess toolchain
|
|
AddJob(Job.Default
|
|
.WithToolchain(InProcessEmitToolchain.Instance)
|
|
.WithWarmupCount(1)
|
|
.WithIterationCount(3));
|
|
|
|
// Configuration options
|
|
WithOptions(ConfigOptions.DisableOptimizationsValidator);
|
|
WithOptions(ConfigOptions.KeepBenchmarkFiles);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Custom configuration for image processing benchmarks
|
|
/// Uses InProcess toolchain to avoid net10.0-windows compatibility issues
|
|
/// </summary>
|
|
public class BenchmarkConfig : ManualConfig
|
|
{
|
|
public BenchmarkConfig()
|
|
{
|
|
// Add console logger
|
|
AddLogger(ConsoleLogger.Default);
|
|
|
|
// Add exporters for different formats
|
|
AddExporter(HtmlExporter.Default);
|
|
AddExporter(MarkdownExporter.GitHub);
|
|
AddExporter(CsvExporter.Default);
|
|
AddExporter(RPlotExporter.Default);
|
|
|
|
// Add diagnosers
|
|
AddDiagnoser(MemoryDiagnoser.Default);
|
|
AddDiagnoser(ThreadingDiagnoser.Default);
|
|
|
|
// Add columns
|
|
AddColumn(StatisticColumn.Mean);
|
|
AddColumn(StatisticColumn.StdDev);
|
|
AddColumn(StatisticColumn.Error);
|
|
AddColumn(StatisticColumn.Min);
|
|
AddColumn(StatisticColumn.Max);
|
|
AddColumn(StatisticColumn.Median);
|
|
AddColumn(BaselineRatioColumn.RatioMean);
|
|
|
|
// Customize jobs with InProcess toolchain for Windows compatibility
|
|
AddJob(Job.Default
|
|
.WithToolchain(InProcessEmitToolchain.Instance)
|
|
.WithWarmupCount(1)
|
|
.WithIterationCount(3)
|
|
.WithId("Quick"));
|
|
|
|
AddJob(Job.Default
|
|
.WithToolchain(InProcessEmitToolchain.Instance)
|
|
.WithWarmupCount(2)
|
|
.WithIterationCount(5)
|
|
.WithId("Standard"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fast configuration for development and quick tests
|
|
/// </summary>
|
|
public static IConfig Fast => new ManualConfig()
|
|
.AddLogger(ConsoleLogger.Default)
|
|
.AddExporter(MarkdownExporter.GitHub)
|
|
.AddDiagnoser(MemoryDiagnoser.Default)
|
|
.AddJob(Job.Dry.WithToolchain(InProcessEmitToolchain.Instance)); // Very fast, but less accurate
|
|
}
|