HPPH/HPPH.Benchmark/BenchmarkHelper.cs

24 lines
693 B
C#

#pragma warning disable CA1416
using HPPH.System.Drawing;
namespace HPPH.Benchmark;
internal static class BenchmarkHelper
{
private const string SAMPLE_DATA_DIR = @"..\..\..\..\..\..\..\..\sample_data";
public static List<T[]> GetSampleData<T>()
where T : struct, IColor
{
if (!Directory.Exists(SAMPLE_DATA_DIR)) throw new Exception("sample data not found!");
List<T[]> colors = [];
IEnumerable<string> files = Directory.EnumerateFiles(SAMPLE_DATA_DIR, "*.png", SearchOption.AllDirectories);
foreach (string file in files)
colors.Add(ImageHelper.LoadImage(file).ConvertTo<T>().ToArray());
return colors;
}
}