(category, getDuration, getParallelism)
| 3302 | * @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback |
| 3303 | */ |
| 3304 | const logByLoadersSummary = (category, getDuration, getParallelism) => { |
| 3305 | /** @type {Map<string, { module: Module, profile: ModuleProfile }[]>} */ |
| 3306 | const map = new Map(); |
| 3307 | for (const [module, profile] of modulesWithProfiles) { |
| 3308 | const list = getOrInsert( |
| 3309 | map, |
| 3310 | `${module.type}!${module.identifier().replace(/(!|^)[^!]*$/, "")}`, |
| 3311 | () => [] |
| 3312 | ); |
| 3313 | list.push({ module, profile }); |
| 3314 | } |
| 3315 | |
| 3316 | let sum = 0; |
| 3317 | let max = 0; |
| 3318 | for (const [key, modules] of map) { |
| 3319 | let innerSum = 0; |
| 3320 | let innerMax = 0; |
| 3321 | for (const { module, profile } of modules) { |
| 3322 | const p = getParallelism(profile); |
| 3323 | const d = getDuration(profile); |
| 3324 | if (d === 0 || p === 0) continue; |
| 3325 | const t = d / p; |
| 3326 | innerSum += t; |
| 3327 | /* istanbul ignore next -- @preserve: only slow (>10ms) modules are logged, timing-dependent */ |
| 3328 | if (t > 10) { |
| 3329 | logByValue( |
| 3330 | t, |
| 3331 | ` | | ${Math.round(t)} ms${ |
| 3332 | p >= 1.1 ? ` (parallelism ${Math.round(p * 10) / 10})` : "" |
| 3333 | } ${category} > ${module.readableIdentifier( |
| 3334 | this.requestShortener |
| 3335 | )}` |
| 3336 | ); |
| 3337 | innerMax = Math.max(innerMax, t); |
| 3338 | } |
| 3339 | } |
| 3340 | sum += innerSum; |
| 3341 | if (innerSum <= 10) continue; |
| 3342 | const idx = key.indexOf("!"); |
| 3343 | const loaders = key.slice(idx + 1); |
| 3344 | const moduleType = key.slice(0, idx); |
| 3345 | const t = Math.max(innerSum / 10, innerMax); |
| 3346 | logByValue( |
| 3347 | t, |
| 3348 | ` | ${Math.round(innerSum)} ms ${category} > ${ |
| 3349 | loaders |
| 3350 | ? `${ |
| 3351 | modules.length |
| 3352 | } x ${moduleType} with ${this.requestShortener.shorten( |
| 3353 | loaders |
| 3354 | )}` |
| 3355 | : `${modules.length} x ${moduleType}` |
| 3356 | }` |
| 3357 | ); |
| 3358 | max = Math.max(max, t); |
| 3359 | } |
| 3360 | if (sum <= 10) return; |
| 3361 | logByValue( |
nothing calls this directly
no test coverage detected