const creator=s=>{const o=s?.ignore??[];return{postcssPlugin:"postcss-slow-plugins",async Once(s,{result:n,postcss:t}){console.log("Analyzing with file:\n  "+s.source?.input.from+"\n");const e=s.source?.input.css??"",i=[...n.processor.plugins.filter(s=>"postcssPlugin"in s&&"postcss-slow-plugins"!==s.postcssPlugin)],p=(await t(i).process(e??"",n.opts)).css.length/1024,medianDuration=async s=>{const o=[];for(let n=0;n<21;n++){const n=performance.now();await s(),o.push(performance.now()-n)}return o.sort((s,o)=>s-o),o[10]},r=await medianDuration(async()=>{await t(i).process(e??"",n.opts)});{const s=[];for(let l=0;l<i.length;l++){const c="postcssPlugin"in i[l]?i[l].postcssPlugin:"unknown plugin";if(o.includes(c))continue;const u=i.filter(s=>s!==i[l]),a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=r-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(p/a).toFixed(2)}kb/ms`,drop:d,name:c,"index in plugins list":l})}s.sort((s,o)=>Number(o.drop)-Number(s.drop)),s.splice(0,0,{duration:`${r.toFixed(2)}ms`,"kb's per ms":`${(p/r).toFixed(2)}kb/ms`,drop:"--",name:"-- all plugins --","index in plugins list":"--"}),s.map(s=>("string"==typeof s.drop||(s.drop=`${s.drop.toFixed(2)}ms`),s)),console.log("Most impactful to improve, ordered by drop in duration when excluded:"),console.table(s.slice(0,11))}{const s=[];for(let l=0;l<i.length;l++){const c="postcssPlugin"in i[l]?i[l].postcssPlugin:"unknown plugin";if(o.includes(c))continue;const u=[...i.filter(s=>s===i[l]||"postcssPlugin"in s&&o.includes(s.postcssPlugin))],a=await medianDuration(async()=>{await t(u).process(e??"",n.opts)}),d=r-a;s.push({duration:`${a.toFixed(2)}ms`,"kb's per ms":`${(p/a).toFixed(2)}kb/ms`,drop:d,name:c,"index in plugins list":l})}s.sort((s,o)=>Number(s.drop)-Number(o.drop)),s.map(s=>(delete s.drop,s)),console.log("Most impactful to improve, ordered by increase in duration when running alone:"),console.table(s.slice(0,11))}}}};creator.postcss=!0;export{creator as default,creator as"module.exports"};
