mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
* Update CommonJSModuleRecord.cpp * smaller * [node:path] Fix crash, mark TODO --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
37 lines
834 B
JavaScript
37 lines
834 B
JavaScript
// so it can run in environments without node module resolution
|
|
import { bench, run } from "./runner.mjs";
|
|
|
|
import crypto from "node:crypto";
|
|
|
|
var foo = Buffer.allocUnsafe(512);
|
|
foo.fill(123);
|
|
|
|
// if ("Bun" in globalThis) {
|
|
// const { CryptoHasher } = Bun;
|
|
// bench("Bun.CryptoHasher(sha512)", () => {
|
|
// var hasher = new CryptoHasher("sha512");
|
|
// hasher.update(foo);
|
|
// hasher.digest();
|
|
// });
|
|
// }
|
|
|
|
bench('crypto.createHash("sha512")', () => {
|
|
var hasher = crypto.createHash("sha512");
|
|
hasher.update(foo);
|
|
hasher.digest();
|
|
});
|
|
|
|
bench('crypto.createHash("sha256")', () => {
|
|
var hasher = crypto.createHash("sha256");
|
|
hasher.update(foo);
|
|
hasher.digest();
|
|
});
|
|
|
|
bench('crypto.createHash("sha1")', () => {
|
|
var hasher = crypto.createHash("sha1");
|
|
hasher.update(foo);
|
|
hasher.digest();
|
|
});
|
|
|
|
await run();
|