Avoid emitting DCE annotations at runtime (#22300)

### What does this PR do?

### How did you verify your code works?
This commit is contained in:
Jarred Sumner
2025-09-01 02:56:59 -07:00
committed by GitHub
parent d957a81c0a
commit 033c977fea
5 changed files with 26 additions and 2 deletions

View File

@@ -12,6 +12,9 @@ const scenarios = [
{ alg: "sha1", digest: "base64" },
{ alg: "sha256", digest: "hex" },
{ alg: "sha256", digest: "base64" },
{ alg: "blake2b512", digest: "hex" },
{ alg: "sha512-224", digest: "hex" },
{ alg: "sha512-256", digest: "hex" },
];
for (const { alg, digest } of scenarios) {
@@ -23,6 +26,10 @@ for (const { alg, digest } of scenarios) {
bench(`${alg}-${digest} (Bun.CryptoHasher)`, () => {
new Bun.CryptoHasher(alg).update(data).digest(digest);
});
bench(`${alg}-${digest} (Bun.CryptoHasher.hash)`, () => {
return Bun.CryptoHasher.hash(alg, data, digest);
});
}
}