2222
2323namespace SixLabors . ImageSharp . Benchmarks . LoadResizeSave
2424{
25+ public enum JpegKind
26+ {
27+ Baseline = 1 ,
28+ Progressive = 2 ,
29+ Any = Baseline | Progressive
30+ }
31+
2532 public class LoadResizeSaveStressRunner
2633 {
2734 private const int ThumbnailSize = 150 ;
@@ -49,6 +56,43 @@ public class LoadResizeSaveStressRunner
4956
5057 public int MaxDegreeOfParallelism { get ; set ; } = - 1 ;
5158
59+ public JpegKind Filter { get ; set ; }
60+
61+ private static readonly string [ ] ProgressiveFiles =
62+ {
63+ "ancyloscelis-apiformis-m-paraguay-face_2014-08-08-095255-zs-pmax_15046500892_o.jpg" ,
64+ "acanthopus-excellens-f-face-brasil_2014-08-06-132105-zs-pmax_14792513890_o.jpg" ,
65+ "bee-ceratina-monster-f-ukraine-face_2014-08-09-123342-zs-pmax_15068816101_o.jpg" ,
66+ "bombus-eximias-f-tawain-face_2014-08-10-094449-zs-pmax_15155452565_o.jpg" ,
67+ "ceratina-14507h1-m-vietnam-face_2014-08-09-163218-zs-pmax_15096718245_o.jpg" ,
68+ "ceratina-buscki-f-panama-face_2014-11-25-140413-zs-pmax_15923736081_o.jpg" ,
69+ "ceratina-tricolor-f-panama-face2_2014-08-29-160402-zs-pmax_14906318297_o.jpg" ,
70+ "ceratina-tricolor-f-panama-face_2014-08-29-160001-zs-pmax_14906300608_o.jpg" ,
71+ "ceratina-tricolor-m-panama-face_2014-08-29-162821-zs-pmax_15069878876_o.jpg" ,
72+ "coelioxys-cayennensis-f-argentina-face_2014-08-09-171932-zs-pmax_14914109737_o.jpg" ,
73+ "ctenocolletes-smaragdinus-f-australia-face_2014-08-08-134825-zs-pmax_14865269708_o.jpg" ,
74+ "diphaglossa-gayi-f-face-chile_2014-08-04-180547-zs-pmax_14918891472_o.jpg" ,
75+ "hylaeus-nubilosus-f-australia-face_2014-08-14-121100-zs-pmax_15049602149_o.jpg" ,
76+ "hypanthidioides-arenaria-f-face-brazil_2014-08-06-061201-zs-pmax_14770371360_o.jpg" ,
77+ "megachile-chalicodoma-species-f-morocco-face_2014-08-14-124840-zs-pmax_15217084686_o.jpg" ,
78+ "megachile-species-f-15266b06-face-kenya_2014-08-06-161044-zs-pmax_14994381392_o.jpg" ,
79+ "megalopta-genalis-m-face-panama-barocolorado_2014-09-19-164939-zs-pmax_15121397069_o.jpg" ,
80+ "melitta-haemorrhoidalis-m--england-face_2014-11-02-014026-zs-pmax-recovered_15782113675_o.jpg" ,
81+ "nomia-heart-antennae-m-15266b02-face-kenya_2014-08-04-195216-zs-pmax_14922843736_o.jpg" ,
82+ "nomia-species-m-oman-face_2014-08-09-192602-zs-pmax_15128732411_o.jpg" ,
83+ "nomia-spiney-m-vietnam-face_2014-08-09-213126-zs-pmax_15191389705_o.jpg" ,
84+ "ochreriades-fasciata-m-face-israel_2014-08-06-084407-zs-pmax_14965515571_o.jpg" ,
85+ "osmia-brevicornisf-jaw-kyrgystan_2014-08-08-103333-zs-pmax_14865267787_o.jpg" ,
86+ "pachyanthidium-aff-benguelense-f-6711f07-face_2014-08-07-112830-zs-pmax_15018069042_o.jpg" ,
87+ "pachymelus-bicolor-m-face-madagascar_2014-08-06-134930-zs-pmax_14801667477_o.jpg" ,
88+ "psaenythia-species-m-argentina-face_2014-08-07-163754-zs-pmax_15007018976_o.jpg" ,
89+ "stingless-bee-1-f-face-peru_2014-07-30-123322-zs-pmax_15633797167_o.jpg" ,
90+ "triepeolus-simplex-m-face-md-kent-county_2014-07-22-100937-zs-pmax_14805405233_o.jpg" ,
91+ "washed-megachile-f-face-chile_2014-08-06-103414-zs-pmax_14977843152_o.jpg" ,
92+ "xylocopa-balck-violetwing-f-kyrgystan-angle_2014-08-09-182433-zs-pmax_15123416061_o.jpg" ,
93+ "xylocopa-india-yellow-m-india-face_2014-08-10-111701-zs-pmax_15166559172_o.jpg" ,
94+ } ;
95+
5296 public void Init ( )
5397 {
5498 if ( RuntimeInformation . OSArchitecture is Architecture . X86 or Architecture . X64 )
@@ -64,10 +108,17 @@ public void Init()
64108 }
65109
66110 // Get at most this.ImageCount images from there
67- this . Images = Directory . EnumerateFiles ( imageDirectory ) . Take ( this . ImageCount ) . ToArray ( ) ;
111+ bool FilterFunc ( string f ) => this . Filter . HasFlag ( GetJpegType ( f ) ) ;
112+
113+ this . Images = Directory . EnumerateFiles ( imageDirectory ) . Where ( FilterFunc ) . Take ( this . ImageCount ) . ToArray ( ) ;
68114
69115 // Create the output directory next to the images directory
70116 this . outputDirectory = TestEnvironment . CreateOutputDirectory ( "MemoryStress" ) ;
117+
118+ static JpegKind GetJpegType ( string f ) =>
119+ ProgressiveFiles . Any ( p => f . EndsWith ( p , StringComparison . OrdinalIgnoreCase ) )
120+ ? JpegKind . Progressive
121+ : JpegKind . Baseline ;
71122 }
72123
73124 public void ForEachImageParallel ( Action < string > action ) => Parallel . ForEach (
0 commit comments