mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-24 19:35:57 +00:00
docs
This commit is contained in:
parent
8c9d159124
commit
828cbbac27
6 changed files with 37 additions and 9 deletions
|
@ -106,7 +106,7 @@ tempfile = { version = "3.13.0" }
|
|||
monero-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" }
|
||||
proptest = { version = "1" }
|
||||
proptest = { version = "1.5.0" }
|
||||
proptest-derive = { version = "0.4.0" }
|
||||
tokio-test = { version = "0.4.4" }
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
//! Benchmarks for `cuprate-json-rpc`.
|
||||
//!
|
||||
//! TODO: this crate is not finished.
|
||||
#![allow(unused_crate_dependencies)]
|
||||
|
||||
mod response;
|
||||
|
||||
criterion::criterion_main! {
|
||||
response::benches,
|
||||
response::serde,
|
||||
}
|
||||
|
|
|
@ -7,8 +7,11 @@ use serde_json::{from_str, to_string_pretty};
|
|||
|
||||
use cuprate_json_rpc::{Id, Response};
|
||||
|
||||
// `serde` benchmarks on `Response`.
|
||||
criterion_group! {
|
||||
benches,
|
||||
name = serde;
|
||||
config = Criterion::default();
|
||||
targets =
|
||||
response_from_str_u8,
|
||||
response_from_str_u64,
|
||||
response_from_str_string_5_len,
|
||||
|
@ -22,7 +25,7 @@ criterion_group! {
|
|||
response_to_string_pretty_string_100_len,
|
||||
response_to_string_pretty_string_500_len,
|
||||
}
|
||||
criterion_main!(benches);
|
||||
criterion_main!(serde);
|
||||
|
||||
/// Generate `from_str` deserialization benchmark functions for [`Response`].
|
||||
macro_rules! impl_from_str_benchmark {
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
//! TODO
|
||||
//! TODO: this crate is not finished.
|
||||
#![allow(unused_crate_dependencies, reason = "used in benchmarks")]
|
||||
|
|
|
@ -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
|
||||
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:
|
||||
[`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.
|
|
@ -4,8 +4,7 @@ New benchmarks are plugged into `cuprate-benchmark` by:
|
|||
1. Registering the benchmark in the `cuprate_benchmark` binary
|
||||
|
||||
See [`benches/benchmark/example`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/example)
|
||||
for an example. For a real example, see:
|
||||
[`cuprate-benchmark-database`](https://github.com/Cuprate/cuprate/tree/main/benches/benchmark/cuprate-database).
|
||||
for an example.
|
||||
|
||||
## Creating the benchmark crate
|
||||
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. 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`
|
||||
This is the trait that standardizes all benchmarks ran under `cuprate-benchmark`.
|
||||
|
||||
|
@ -43,3 +49,9 @@ cfg_if! {
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 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.
|
Loading…
Reference in a new issue