-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnostr-wasm.bench.ts
69 lines (52 loc) · 1.26 KB
/
nostr-wasm.bench.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { initNostrWasm } from "npm:nostr-wasm";
import { bytesToHex } from "npm:@noble/hashes/utils";
Deno.bench("initNostrWasm", async () => {
await initNostrWasm();
});
Deno.bench("generateSecretKey", async (b) => {
const nostr = await initNostrWasm();
b.start();
nostr.generateSecretKey();
b.end();
});
Deno.bench("getPublicKey", async (b) => {
const nostr = await initNostrWasm();
const seckey = nostr.generateSecretKey();
b.start();
nostr.getPublicKey(seckey);
b.end();
});
Deno.bench("finalizeEvent", async (b) => {
const nostr = await initNostrWasm();
const seckey = nostr.generateSecretKey();
const pubkey = nostr.getPublicKey(seckey);
b.start();
await nostr.finalizeEvent({
kind: 1,
pubkey: bytesToHex(pubkey),
content: "",
tags: [],
created_at: 0,
id: "",
sig: "",
}, seckey);
b.end();
});
Deno.bench("verifyEvent", async (b) => {
const nostr = await initNostrWasm();
const seckey = nostr.generateSecretKey();
const pubkey = nostr.getPublicKey(seckey);
const event = {
kind: 1,
pubkey: bytesToHex(pubkey),
content: "",
tags: [],
created_at: 0,
id: "",
sig: "",
};
await nostr.finalizeEvent(event, seckey);
b.start();
nostr.verifyEvent(event);
b.end();
});