deno.land / std@0.224.0 / crypto / testdata / digest_many_calls.ts

digest_many_calls.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { crypto as stdCrypto } from "../crypto.ts";import { instantiateWithInstance } from "../_wasm/lib/deno_std_wasm_crypto.generated.mjs";import { encodeHex } from "../../encoding/hex.ts";
const memory = instantiateWithInstance().instance.exports .memory as WebAssembly.Memory;
const heapBytesInitial = memory.buffer.byteLength;
let state = new ArrayBuffer(0);
for (let i = 0; i < 1_000_000; i++) { state = stdCrypto.subtle.digestSync({ name: "BLAKE3", }, state);}
const heapBytesFinal = memory.buffer.byteLength;
const stateFinal = encodeHex(state);
console.log(JSON.stringify({ heapBytesInitial, heapBytesFinal, stateFinal,}));
std

Version Info

Tagged at
7 months ago