Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 163 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 28 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
[workspace]
members = [
"crates/*",
"crates/*",

# Nostr SDK
"sdk",
# Nostr SDK
"sdk",

# Nostr Database
"database/nostr-database",
"database/nostr-database-test-suite",
"database/nostr-lmdb",
"database/nostr-memory",
"database/nostr-ndb",
"database/nostr-sqlite",
# Nostr Database
"database/nostr-database",
"database/nostr-database-test-suite",
"database/nostr-lmdb",
"database/nostr-memory",
"database/nostr-ndb",
"database/nostr-sqlite",

# Gossip
"gossip/nostr-gossip",
"gossip/nostr-gossip-memory",
"gossip/nostr-gossip-sqlite",
"gossip/nostr-gossip-test-suite",
# Gossip
"gossip/nostr-gossip",
"gossip/nostr-gossip-memory",
"gossip/nostr-gossip-sqlite",
"gossip/nostr-gossip-test-suite",

# Remote File Storage implementations
"rfs/nostr-blossom",
"rfs/nostr-http-file-storage",
# Remote File Storage implementations
"rfs/nostr-blossom",
"rfs/nostr-http-file-storage",

# Signers
"signer/nostr-browser-signer",
"signer/nostr-browser-signer-proxy",
"signer/nostr-connect",
# Signers
"signer/nostr-browser-signer",
"signer/nostr-browser-signer-proxy",
"signer/nostr-connect",
"benches",
]
default-members = ["crates/*"]
resolver = "2"

[workspace.package]
edition = "2024"
authors = ["Yuki Kishimoto <yukikishimoto@protonmail.com>", "Rust Nostr Developers"]
authors = [
"Yuki Kishimoto <yukikishimoto@protonmail.com>",
"Rust Nostr Developers",
]
homepage = "https://github.com/rust-nostr/nostr"
repository = "https://github.com/rust-nostr/nostr.git"
license = "MIT"
rust-version = "1.85.0"

[workspace.dependencies]
async-utility = "0.3"
async-wsocket = { git = "https://github.com/shadowylab/async-wsocket", rev = "0fed6c9c6aec7393ee0e9cf3933d76914ab427d3" }
async-wsocket = { git = "https://github.com/shadowylab/async-wsocket", rev = "0fed6c9c6aec7393ee0e9cf3933d76914ab427d3" }
atomic-destructor = { version = "0.3", default-features = false }
base64 = { version = "0.22", default-features = false }
btreecap = "0.1"
Expand Down
23 changes: 23 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "benches"
version = "0.0.0"
edition.workspace = true
authors.workspace = true
license.workspace = true
publish = false
autobins = false

[dependencies]
criterion = { version = "0.7", features = ["html_reports"] }
nostr = { workspace = true, features = ["std", "os-rng"] }
nostr-sdk.workspace = true
nostr-database = { workspace = true, features = ["flatbuf"] }
tokio.workspace = true

[[bench]]
name = "bench_main"
path = "src/main.rs"
harness = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bench)'] }
48 changes: 48 additions & 0 deletions benches/src/database.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) 2022-2023 Yuki Kishimoto
// Copyright (c) 2023-2025 Rust Nostr Developers
// Distributed under the MIT software license

use std::hint::black_box;

use criterion::Criterion;
use nostr::prelude::*;
use nostr_database::flatbuffers::FlatBufferDecodeBorrowed;
use nostr_database::{FlatBufferBuilder, FlatBufferEncode};

pub fn decode_flatbuf_event_borrow(c: &mut Criterion) {
let json = r#"{
"content": "+",
"created_at": 1716508454,
"id": "3e9e9c2fbf263590860a9c60a7de6b0d166230a5a15aa8dcdb70f537cec9807a",
"kind": 7,
"pubkey": "3bbddb5c7233ad993b41cb639e63122120f391b8580a9b83aae33c648230e0a3",
"sig": "3f2ba6d713e4851500b81de2d2ef44b72f1eff061898bf8488e74f7e4ed141b0dadab4c3a9c6b237f3a6db83171bd41eafd7ab973f6fb067a4305e95abeadeee",
"tags": [
[
"e",
"e1e786c60ed884b6e784712aaf70e63b848b7403ef651b52b701d87739ea1808",
"",
"",
"04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9"
],
[
"p",
"04c915daefee38317fa734444acee390a8269fe5810b2241e5e6dd343dfbecc9"
]
]
}"#;
let event = Event::from_json(json).unwrap();

let mut fbb = FlatBufferBuilder::new();
let bytes = event.encode(&mut fbb);

c.bench_function("decode_flatbuf_event_borrow", |bh| {
bh.iter(|| {
black_box(EventBorrow::decode(bytes)).unwrap();
})
});
}

pub fn benches(c: &mut Criterion) {
decode_flatbuf_event_borrow(c);
}
Loading
Loading