Skip to content

Commit

Permalink
fix: use standardized units in text outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
n-peugnet committed May 26, 2024
1 parent 67cbf87 commit 07e96c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1146,13 +1146,13 @@ func (ctx *internalContext) Dispose() {
func prettyPrintByteCount(n int) string {
var size string
if n < 1024 {
size = fmt.Sprintf("%db ", n)
size = fmt.Sprintf("%dB ", n)
} else if n < 1024*1024 {
size = fmt.Sprintf("%.1fkb", float64(n)/(1024))
size = fmt.Sprintf("%.1fKiB", float64(n)/(1024))
} else if n < 1024*1024*1024 {
size = fmt.Sprintf("%.1fmb", float64(n)/(1024*1024))
size = fmt.Sprintf("%.1fMiB", float64(n)/(1024*1024))
} else {
size = fmt.Sprintf("%.1fgb", float64(n)/(1024*1024*1024))
size = fmt.Sprintf("%.1fGiB", float64(n)/(1024*1024*1024))
}
return size
}
Expand Down
24 changes: 12 additions & 12 deletions scripts/js-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6962,15 +6962,15 @@ let analyzeTests = {
}
}
assert.strictEqual(await esbuild.analyzeMetafile(metafile), `
out.js 100b 100.0%
├ lib.js 50b 50.0%
└ entry.js 25b 25.0%
out.js 100B 100.0%
├ lib.js 50B 50.0%
└ entry.js 25B 25.0%
`)
assert.strictEqual(await esbuild.analyzeMetafile(metafile, { verbose: true }), `
out.js ────── 100b ── 100.0%
├ lib.js ──── 50b ─── 50.0%
out.js ────── 100B ─── 100.0%
├ lib.js ──── 50B ──── 50.0%
│ └ entry.js
└ entry.js ── 25b ─── 25.0%
└ entry.js ── 25B ──── 25.0%
`)
},
}
Expand Down Expand Up @@ -7192,15 +7192,15 @@ ${path.relative(process.cwd(), input).split(path.sep).join('/')}:1:2: ERROR: Une
}
}
assert.strictEqual(esbuild.analyzeMetafileSync(metafile), `
out.js 100b 100.0%
├ lib.js 50b 50.0%
└ entry.js 25b 25.0%
out.js 100B 100.0%
├ lib.js 50B 50.0%
└ entry.js 25B 25.0%
`)
assert.strictEqual(esbuild.analyzeMetafileSync(metafile, { verbose: true }), `
out.js ────── 100b ── 100.0%
├ lib.js ──── 50b ─── 50.0%
out.js ────── 100B ─── 100.0%
├ lib.js ──── 50B ──── 50.0%
│ └ entry.js
└ entry.js ── 25b ─── 25.0%
└ entry.js ── 25B ──── 25.0%
`)
},
}
Expand Down

0 comments on commit 07e96c2

Please sign in to comment.