docs
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled

This commit is contained in:
hinto.janai 2024-10-08 20:49:13 -04:00
parent 8c9d159124
commit 828cbbac27
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
6 changed files with 37 additions and 9 deletions

View file

@ -106,7 +106,7 @@ tempfile = { version = "3.13.0" }
monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" } monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" }
monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" } monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" }
pretty_assertions = { version = "1.4.1" } pretty_assertions = { version = "1.4.1" }
proptest = { version = "1" } proptest = { version = "1.5.0" }
proptest-derive = { version = "0.4.0" } proptest-derive = { version = "0.4.0" }
tokio-test = { version = "0.4.4" } tokio-test = { version = "0.4.4" }

View file

@ -1,8 +1,10 @@
//! Benchmarks for `cuprate-json-rpc`. //! Benchmarks for `cuprate-json-rpc`.
//!
//! TODO: this crate is not finished.
#![allow(unused_crate_dependencies)] #![allow(unused_crate_dependencies)]
mod response; mod response;
criterion::criterion_main! { criterion::criterion_main! {
response::benches, response::serde,
} }

View file

@ -7,8 +7,11 @@ use serde_json::{from_str, to_string_pretty};
use cuprate_json_rpc::{Id, Response}; use cuprate_json_rpc::{Id, Response};
// `serde` benchmarks on `Response`.
criterion_group! { criterion_group! {
benches, name = serde;
config = Criterion::default();
targets =
response_from_str_u8, response_from_str_u8,
response_from_str_u64, response_from_str_u64,
response_from_str_string_5_len, response_from_str_string_5_len,
@ -22,7 +25,7 @@ criterion_group! {
response_to_string_pretty_string_100_len, response_to_string_pretty_string_100_len,
response_to_string_pretty_string_500_len, response_to_string_pretty_string_500_len,
} }
criterion_main!(benches); criterion_main!(serde);
/// Generate `from_str` deserialization benchmark functions for [`Response`]. /// Generate `from_str` deserialization benchmark functions for [`Response`].
macro_rules! impl_from_str_benchmark { macro_rules! impl_from_str_benchmark {

View file

@ -1,2 +1,2 @@
//! TODO //! TODO: this crate is not finished.
#![allow(unused_crate_dependencies, reason = "used in benchmarks")] #![allow(unused_crate_dependencies, reason = "used in benchmarks")]

View file

@ -6,5 +6,16 @@ although, it requires knowledge of how to use Criterion first:
2. Copy [`benches/criterion/example`](https://github.com/Cuprate/cuprate/tree/main/benches/criterion/example) as base 2. Copy [`benches/criterion/example`](https://github.com/Cuprate/cuprate/tree/main/benches/criterion/example) as base
3. Get started 3. Get started
## Naming
New benchmark crates using Criterion should:
- Be in [`benches/criterion/`](https://github.com/Cuprate/cuprate/tree/main/benches/criterion/)
- Be in the `cuprate-criterion-$CRATE_NAME` format
For a real example, see: For a real example, see:
[`cuprate-criterion-json-rpc`](https://github.com/Cuprate/cuprate/tree/main/benches/criterion/cuprate-json-rpc). [`cuprate-criterion-json-rpc`](https://github.com/Cuprate/cuprate/tree/main/benches/criterion/cuprate-json-rpc).
## Workspace
Finally, make sure to add the benchmark crate to the workspace
[`Cargo.toml`](https://github.com/Cuprate/cuprate/blob/main/Cargo.toml) file.
Your benchmark is now ready to be ran.

View file

@ -4,8 +4,7 @@ New benchmarks are plugged into `cuprate-benchmark` by:
1. Registering the benchmark in the `cuprate_benchmark` binary 1. Registering the benchmark in the `cuprate_benchmark` binary
See [`benches/benchmark/example`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/example) See [`benches/benchmark/example`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/example)
for an example. For a real example, see: for an example.
[`cuprate-benchmark-database`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/cuprate-database).
## Creating the benchmark crate ## Creating the benchmark crate
Before plugging into `cuprate-benchmark`, your actual benchmark crate must be created: Before plugging into `cuprate-benchmark`, your actual benchmark crate must be created:
@ -15,6 +14,13 @@ Before plugging into `cuprate-benchmark`, your actual benchmark crate must be cr
1. Create a benchmark 1. Create a benchmark
1. Implement `cuprate_benchmark_lib::Benchmark` 1. Implement `cuprate_benchmark_lib::Benchmark`
New benchmark crates using `cuprate-database` should:
- Be in [`benches/benchmark/`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/)
- Be in the `cuprate-benchmark-$CRATE_NAME` format
For a real example, see:
[`cuprate-benchmark-database`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/cuprate-database).
## `cuprate_benchmark_lib::Benchmark` ## `cuprate_benchmark_lib::Benchmark`
This is the trait that standardizes all benchmarks ran under `cuprate-benchmark`. This is the trait that standardizes all benchmarks ran under `cuprate-benchmark`.
@ -42,4 +48,10 @@ cfg_if! {
run::run_benchmark::<cuprate_benchmark_egg::Benchmark>(&mut timings); run::run_benchmark::<cuprate_benchmark_egg::Benchmark>(&mut timings);
} }
} }
``` ```
## Workspace
Finally, make sure to add the benchmark crate to the workspace
[`Cargo.toml`](https://github.com/Cuprate/cuprate/blob/main/Cargo.toml) file.
Your benchmark is now ready to be ran.