Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowCait committed Aug 22, 2024
1 parent 9237d6c commit 487d66b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 37 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Benchmark Nostr libraries' functions.

## Benchamarks

Full log is [here](https://github.com/SnowCait/nostr-library-benchmarks/actions/runs/10505736826).
Full log is
[here](https://github.com/SnowCait/nostr-library-benchmarks/actions/runs/10505736826).

### TypeScript (JavaScript)

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/SnowCait/nostr-library-benchmarks

go 1.22.3

require github.com/nbd-wtf/go-nostr v0.34.10

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect
Expand All @@ -12,7 +14,6 @@ require (
github.com/gobwas/ws v1.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/nbd-wtf/go-nostr v0.34.10 // indirect
github.com/puzpuzpuz/xsync/v3 v3.0.2 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
Expand All @@ -28,6 +30,8 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o=
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2 changes: 1 addition & 1 deletion ndk.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Deno.bench("isValid", async (b) => {

b.start();

event.isValid;
event.verifySignature(false);

b.end();
});
3 changes: 3 additions & 0 deletions nostr-tools.bench.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {
Event,
finalizeEvent,
generateSecretKey,
getEventHash,
getPublicKey,
serializeEvent,
verifiedSymbol,
verifyEvent,
} from "npm:nostr-tools";

Expand Down Expand Up @@ -48,6 +50,7 @@ Deno.bench("verifyEvent", (b) => {
{ kind: 1, content: "", tags: [], created_at: 0 },
seckey,
);
(event as Event)[verifiedSymbol] = undefined;

b.start();

Expand Down
68 changes: 34 additions & 34 deletions rust-nostr.bench.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { EventBuilder, Keys, loadWasmAsync } from "npm:@rust-nostr/nostr";

Deno.bench("generate", async (b) => {
await loadWasmAsync();

b.start();

Keys.generate();

b.end();
});

Deno.bench("toEvent", async (b) => {
await loadWasmAsync();
const keys = Keys.generate();

b.start();

new EventBuilder(1, "", []).toEvent(keys).asJson();

b.end();
});

Deno.bench("verify", async (b) => {
await loadWasmAsync();
const keys = Keys.generate();
const event = new EventBuilder(1, "", []).toEvent(keys);

b.start();

event.verify();

b.end();
});
import { EventBuilder, Keys, loadWasmAsync } from "npm:@rust-nostr/nostr";

Deno.bench("generate", async (b) => {
await loadWasmAsync();

b.start();

Keys.generate();

b.end();
});

Deno.bench("toEvent", async (b) => {
await loadWasmAsync();
const keys = Keys.generate();

b.start();

new EventBuilder(1, "", []).toEvent(keys).asJson();

b.end();
});

Deno.bench("verify", async (b) => {
await loadWasmAsync();
const keys = Keys.generate();
const event = new EventBuilder(1, "", []).toEvent(keys);

b.start();

event.verify();

b.end();
});

0 comments on commit 487d66b

Please sign in to comment.