mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-22 11:39:30 +00:00
add tmp_env_all_threads()
This commit is contained in:
parent
3ffa63789a
commit
207f4a1ca2
9 changed files with 105 additions and 67 deletions
|
@ -44,4 +44,5 @@ Each file represents some logical benchmark grouping.
|
||||||
| `db_multi_thread.rs` | Same as `db.rs` but multi-threaded
|
| `db_multi_thread.rs` | Same as `db.rs` but multi-threaded
|
||||||
| `env.rs` | `trait {Env, EnvInner, TxR{o,w}, Tables[Mut]}` benchmarks
|
| `env.rs` | `trait {Env, EnvInner, TxR{o,w}, Tables[Mut]}` benchmarks
|
||||||
| `env_multi_thread.rs` | Same as `env.rs` but multi-threaded
|
| `env_multi_thread.rs` | Same as `env.rs` but multi-threaded
|
||||||
|
| `service.rs` | `cuprate_database::service` benchmarks
|
||||||
| `storable.rs` | `trait Storable` benchmarks
|
| `storable.rs` | `trait Storable` benchmarks
|
|
@ -1,4 +1,4 @@
|
||||||
//! TODO
|
//! `trait Database{Ro,Rw,Iter}` benchmarks.
|
||||||
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ use cuprate_database::{
|
||||||
DatabaseIter, DatabaseRo, DatabaseRw, Env, EnvInner, TxRw,
|
DatabaseIter, DatabaseRo, DatabaseRw, Env, EnvInner, TxRw,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_database_benchmark::tmp_concrete_env;
|
use cuprate_database_benchmark::tmp_env;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Criterion
|
//---------------------------------------------------------------------------------------------------- Criterion
|
||||||
criterion_group! {
|
criterion_group! {
|
||||||
|
@ -66,7 +66,7 @@ const VALUE: Output = Output {
|
||||||
/// [`DatabaseRo::get`]
|
/// [`DatabaseRo::get`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_get(c: &mut Criterion) {
|
fn ro_get(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -88,7 +88,7 @@ fn ro_get(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::len`]
|
/// [`DatabaseRo::len`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_len(c: &mut Criterion) {
|
fn ro_len(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -110,7 +110,7 @@ fn ro_len(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::first`]
|
/// [`DatabaseRo::first`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_first(c: &mut Criterion) {
|
fn ro_first(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -132,7 +132,7 @@ fn ro_first(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::last`]
|
/// [`DatabaseRo::last`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_last(c: &mut Criterion) {
|
fn ro_last(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -154,7 +154,7 @@ fn ro_last(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::is_empty`]
|
/// [`DatabaseRo::is_empty`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_is_empty(c: &mut Criterion) {
|
fn ro_is_empty(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -176,7 +176,7 @@ fn ro_is_empty(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::contains`]
|
/// [`DatabaseRo::contains`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_contains(c: &mut Criterion) {
|
fn ro_contains(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -203,7 +203,7 @@ fn ro_contains(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::get`]
|
/// [`DatabaseRo::get`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_get(c: &mut Criterion) {
|
fn rw_get(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -225,7 +225,7 @@ fn rw_get(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::len`]
|
/// [`DatabaseRo::len`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_len(c: &mut Criterion) {
|
fn rw_len(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -247,7 +247,7 @@ fn rw_len(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::first`]
|
/// [`DatabaseRo::first`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_first(c: &mut Criterion) {
|
fn rw_first(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -269,7 +269,7 @@ fn rw_first(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::last`]
|
/// [`DatabaseRo::last`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_last(c: &mut Criterion) {
|
fn rw_last(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -291,7 +291,7 @@ fn rw_last(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::is_empty`]
|
/// [`DatabaseRo::is_empty`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_is_empty(c: &mut Criterion) {
|
fn rw_is_empty(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -313,7 +313,7 @@ fn rw_is_empty(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::contains`]
|
/// [`DatabaseRo::contains`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_contains(c: &mut Criterion) {
|
fn rw_contains(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -336,7 +336,7 @@ fn rw_contains(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::put`]
|
/// [`DatabaseRw::put`]
|
||||||
#[named]
|
#[named]
|
||||||
fn put(c: &mut Criterion) {
|
fn put(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -354,7 +354,7 @@ fn put(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::delete`]
|
/// [`DatabaseRw::delete`]
|
||||||
#[named]
|
#[named]
|
||||||
fn delete(c: &mut Criterion) {
|
fn delete(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -383,7 +383,7 @@ fn delete(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::pop_first`]
|
/// [`DatabaseRw::pop_first`]
|
||||||
#[named]
|
#[named]
|
||||||
fn pop_first(c: &mut Criterion) {
|
fn pop_first(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -412,7 +412,7 @@ fn pop_first(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::pop_last`]
|
/// [`DatabaseRw::pop_last`]
|
||||||
#[named]
|
#[named]
|
||||||
fn pop_last(c: &mut Criterion) {
|
fn pop_last(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -442,7 +442,7 @@ fn pop_last(c: &mut Criterion) {
|
||||||
// /// [`DatabaseRw::take`]
|
// /// [`DatabaseRw::take`]
|
||||||
// #[named]
|
// #[named]
|
||||||
// fn take(c: &mut Criterion) {
|
// fn take(c: &mut Criterion) {
|
||||||
// let (env, _tempdir) = tmp_concrete_env();
|
// let (env, _tempdir) = tmp_env();
|
||||||
// let env_inner = env.env_inner();
|
// let env_inner = env.env_inner();
|
||||||
// let tx_rw = env_inner.tx_rw().unwrap();
|
// let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
// let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
// let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -465,7 +465,7 @@ fn pop_last(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::get_range`]
|
/// [`DatabaseRo::get_range`]
|
||||||
#[named]
|
#[named]
|
||||||
fn get_range(c: &mut Criterion) {
|
fn get_range(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -495,7 +495,7 @@ fn get_range(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::iter`]
|
/// [`DatabaseRo::iter`]
|
||||||
#[named]
|
#[named]
|
||||||
fn iter(c: &mut Criterion) {
|
fn iter(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -525,7 +525,7 @@ fn iter(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::keys`]
|
/// [`DatabaseRo::keys`]
|
||||||
#[named]
|
#[named]
|
||||||
fn keys(c: &mut Criterion) {
|
fn keys(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -555,7 +555,7 @@ fn keys(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::values`]
|
/// [`DatabaseRo::values`]
|
||||||
#[named]
|
#[named]
|
||||||
fn values(c: &mut Criterion) {
|
fn values(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! Same as `db.rs` but multi-threaded.
|
||||||
//! TODO: create multi-threaded benchmarks
|
//! TODO: create multi-threaded benchmarks
|
||||||
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
@ -13,7 +14,7 @@ use cuprate_database::{
|
||||||
DatabaseIter, DatabaseRo, DatabaseRw, Env, EnvInner, TxRw,
|
DatabaseIter, DatabaseRo, DatabaseRw, Env, EnvInner, TxRw,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_database_benchmark::tmp_concrete_env;
|
use cuprate_database_benchmark::tmp_env_all_threads;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Criterion
|
//---------------------------------------------------------------------------------------------------- Criterion
|
||||||
criterion_group! {
|
criterion_group! {
|
||||||
|
@ -66,7 +67,7 @@ const VALUE: Output = Output {
|
||||||
/// [`DatabaseRo::get`]
|
/// [`DatabaseRo::get`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_get(c: &mut Criterion) {
|
fn ro_get(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -88,7 +89,7 @@ fn ro_get(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::len`]
|
/// [`DatabaseRo::len`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_len(c: &mut Criterion) {
|
fn ro_len(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -110,7 +111,7 @@ fn ro_len(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::first`]
|
/// [`DatabaseRo::first`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_first(c: &mut Criterion) {
|
fn ro_first(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -132,7 +133,7 @@ fn ro_first(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::last`]
|
/// [`DatabaseRo::last`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_last(c: &mut Criterion) {
|
fn ro_last(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -154,7 +155,7 @@ fn ro_last(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::is_empty`]
|
/// [`DatabaseRo::is_empty`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_is_empty(c: &mut Criterion) {
|
fn ro_is_empty(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -176,7 +177,7 @@ fn ro_is_empty(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::contains`]
|
/// [`DatabaseRo::contains`]
|
||||||
#[named]
|
#[named]
|
||||||
fn ro_contains(c: &mut Criterion) {
|
fn ro_contains(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -203,7 +204,7 @@ fn ro_contains(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::get`]
|
/// [`DatabaseRo::get`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_get(c: &mut Criterion) {
|
fn rw_get(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -225,7 +226,7 @@ fn rw_get(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::len`]
|
/// [`DatabaseRo::len`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_len(c: &mut Criterion) {
|
fn rw_len(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -247,7 +248,7 @@ fn rw_len(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::first`]
|
/// [`DatabaseRo::first`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_first(c: &mut Criterion) {
|
fn rw_first(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -269,7 +270,7 @@ fn rw_first(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::last`]
|
/// [`DatabaseRo::last`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_last(c: &mut Criterion) {
|
fn rw_last(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -291,7 +292,7 @@ fn rw_last(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::is_empty`]
|
/// [`DatabaseRo::is_empty`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_is_empty(c: &mut Criterion) {
|
fn rw_is_empty(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -313,7 +314,7 @@ fn rw_is_empty(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::contains`]
|
/// [`DatabaseRo::contains`]
|
||||||
#[named]
|
#[named]
|
||||||
fn rw_contains(c: &mut Criterion) {
|
fn rw_contains(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -336,7 +337,7 @@ fn rw_contains(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::put`]
|
/// [`DatabaseRw::put`]
|
||||||
#[named]
|
#[named]
|
||||||
fn put(c: &mut Criterion) {
|
fn put(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -354,7 +355,7 @@ fn put(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::delete`]
|
/// [`DatabaseRw::delete`]
|
||||||
#[named]
|
#[named]
|
||||||
fn delete(c: &mut Criterion) {
|
fn delete(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -383,7 +384,7 @@ fn delete(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::pop_first`]
|
/// [`DatabaseRw::pop_first`]
|
||||||
#[named]
|
#[named]
|
||||||
fn pop_first(c: &mut Criterion) {
|
fn pop_first(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -412,7 +413,7 @@ fn pop_first(c: &mut Criterion) {
|
||||||
/// [`DatabaseRw::pop_last`]
|
/// [`DatabaseRw::pop_last`]
|
||||||
#[named]
|
#[named]
|
||||||
fn pop_last(c: &mut Criterion) {
|
fn pop_last(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -442,7 +443,7 @@ fn pop_last(c: &mut Criterion) {
|
||||||
// /// [`DatabaseRw::take`]
|
// /// [`DatabaseRw::take`]
|
||||||
// #[named]
|
// #[named]
|
||||||
// fn take(c: &mut Criterion) {
|
// fn take(c: &mut Criterion) {
|
||||||
// let (env, _tempdir) = tmp_concrete_env();
|
// let (env, _tempdir) = tmp_env_all_threads();
|
||||||
// let env_inner = env.env_inner();
|
// let env_inner = env.env_inner();
|
||||||
// let tx_rw = env_inner.tx_rw().unwrap();
|
// let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
// let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
// let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -465,7 +466,7 @@ fn pop_last(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::get_range`]
|
/// [`DatabaseRo::get_range`]
|
||||||
#[named]
|
#[named]
|
||||||
fn get_range(c: &mut Criterion) {
|
fn get_range(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -495,7 +496,7 @@ fn get_range(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::iter`]
|
/// [`DatabaseRo::iter`]
|
||||||
#[named]
|
#[named]
|
||||||
fn iter(c: &mut Criterion) {
|
fn iter(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -525,7 +526,7 @@ fn iter(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::keys`]
|
/// [`DatabaseRo::keys`]
|
||||||
#[named]
|
#[named]
|
||||||
fn keys(c: &mut Criterion) {
|
fn keys(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
@ -555,7 +556,7 @@ fn keys(c: &mut Criterion) {
|
||||||
/// [`DatabaseRo::values`]
|
/// [`DatabaseRo::values`]
|
||||||
#[named]
|
#[named]
|
||||||
fn values(c: &mut Criterion) {
|
fn values(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
let mut table = env_inner.open_db_rw::<Outputs>(&tx_rw).unwrap();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! TODO
|
//! `trait {Env, EnvInner, TxR{o,w}, Tables[Mut]}` benchmarks.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
@ -12,7 +12,7 @@ use cuprate_database::{
|
||||||
ConcreteEnv, Env, EnvInner, TxRo, TxRw,
|
ConcreteEnv, Env, EnvInner, TxRo, TxRw,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_database_benchmark::tmp_concrete_env;
|
use cuprate_database_benchmark::tmp_env;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Criterion
|
//---------------------------------------------------------------------------------------------------- Criterion
|
||||||
criterion_group! {
|
criterion_group! {
|
||||||
|
@ -46,7 +46,7 @@ fn open(c: &mut Criterion) {
|
||||||
/// [`Env::env_inner`].
|
/// [`Env::env_inner`].
|
||||||
#[named]
|
#[named]
|
||||||
fn env_inner(c: &mut Criterion) {
|
fn env_inner(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
@ -58,7 +58,7 @@ fn env_inner(c: &mut Criterion) {
|
||||||
/// Create and commit read-only transactions.
|
/// Create and commit read-only transactions.
|
||||||
#[named]
|
#[named]
|
||||||
fn tx_ro(c: &mut Criterion) {
|
fn tx_ro(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
|
@ -72,7 +72,7 @@ fn tx_ro(c: &mut Criterion) {
|
||||||
/// Create and commit read/write transactions.
|
/// Create and commit read/write transactions.
|
||||||
#[named]
|
#[named]
|
||||||
fn tx_rw(c: &mut Criterion) {
|
fn tx_rw(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
|
@ -86,7 +86,7 @@ fn tx_rw(c: &mut Criterion) {
|
||||||
/// Open all database tables in read-only mode.
|
/// Open all database tables in read-only mode.
|
||||||
#[named]
|
#[named]
|
||||||
fn open_tables(c: &mut Criterion) {
|
fn open_tables(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_ro = env_inner.tx_ro().unwrap();
|
let tx_ro = env_inner.tx_ro().unwrap();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ fn open_tables(c: &mut Criterion) {
|
||||||
/// Open all database tables in read/write mode.
|
/// Open all database tables in read/write mode.
|
||||||
#[named]
|
#[named]
|
||||||
fn open_tables_mut(c: &mut Criterion) {
|
fn open_tables_mut(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ fn open_tables_mut(c: &mut Criterion) {
|
||||||
/// `Env` memory map resizes.
|
/// `Env` memory map resizes.
|
||||||
#[named]
|
#[named]
|
||||||
fn resize(c: &mut Criterion) {
|
fn resize(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
|
|
||||||
// Resize by the OS page size.
|
// Resize by the OS page size.
|
||||||
let page_size = page_size();
|
let page_size = page_size();
|
||||||
|
@ -136,7 +136,7 @@ fn resize(c: &mut Criterion) {
|
||||||
/// Access current memory map size of the database.
|
/// Access current memory map size of the database.
|
||||||
#[named]
|
#[named]
|
||||||
fn current_map_size(c: &mut Criterion) {
|
fn current_map_size(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
@ -151,7 +151,7 @@ fn current_map_size(c: &mut Criterion) {
|
||||||
/// Access on-disk size of the database.
|
/// Access on-disk size of the database.
|
||||||
#[named]
|
#[named]
|
||||||
fn disk_size_bytes(c: &mut Criterion) {
|
fn disk_size_bytes(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! Same as `env.rs` but multi-threaded.
|
||||||
//! TODO: create multi-threaded benchmarks
|
//! TODO: create multi-threaded benchmarks
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
|
@ -12,7 +13,7 @@ use cuprate_database::{
|
||||||
ConcreteEnv, Env, EnvInner, TxRo, TxRw,
|
ConcreteEnv, Env, EnvInner, TxRo, TxRw,
|
||||||
};
|
};
|
||||||
|
|
||||||
use cuprate_database_benchmark::tmp_concrete_env;
|
use cuprate_database_benchmark::tmp_env_all_threads;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Criterion
|
//---------------------------------------------------------------------------------------------------- Criterion
|
||||||
criterion_group! {
|
criterion_group! {
|
||||||
|
@ -46,7 +47,7 @@ fn open(c: &mut Criterion) {
|
||||||
/// [`Env::env_inner`].
|
/// [`Env::env_inner`].
|
||||||
#[named]
|
#[named]
|
||||||
fn env_inner(c: &mut Criterion) {
|
fn env_inner(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
@ -58,7 +59,7 @@ fn env_inner(c: &mut Criterion) {
|
||||||
/// Create and commit read-only transactions.
|
/// Create and commit read-only transactions.
|
||||||
#[named]
|
#[named]
|
||||||
fn tx_ro(c: &mut Criterion) {
|
fn tx_ro(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
|
@ -72,7 +73,7 @@ fn tx_ro(c: &mut Criterion) {
|
||||||
/// Create and commit read/write transactions.
|
/// Create and commit read/write transactions.
|
||||||
#[named]
|
#[named]
|
||||||
fn tx_rw(c: &mut Criterion) {
|
fn tx_rw(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
|
@ -86,7 +87,7 @@ fn tx_rw(c: &mut Criterion) {
|
||||||
/// Open all database tables in read-only mode.
|
/// Open all database tables in read-only mode.
|
||||||
#[named]
|
#[named]
|
||||||
fn open_tables(c: &mut Criterion) {
|
fn open_tables(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_ro = env_inner.tx_ro().unwrap();
|
let tx_ro = env_inner.tx_ro().unwrap();
|
||||||
|
|
||||||
|
@ -102,7 +103,7 @@ fn open_tables(c: &mut Criterion) {
|
||||||
/// Open all database tables in read/write mode.
|
/// Open all database tables in read/write mode.
|
||||||
#[named]
|
#[named]
|
||||||
fn open_tables_mut(c: &mut Criterion) {
|
fn open_tables_mut(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
let env_inner = env.env_inner();
|
let env_inner = env.env_inner();
|
||||||
let tx_rw = env_inner.tx_rw().unwrap();
|
let tx_rw = env_inner.tx_rw().unwrap();
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ fn open_tables_mut(c: &mut Criterion) {
|
||||||
/// `Env` memory map resizes.
|
/// `Env` memory map resizes.
|
||||||
#[named]
|
#[named]
|
||||||
fn resize(c: &mut Criterion) {
|
fn resize(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
|
|
||||||
// Resize by the OS page size.
|
// Resize by the OS page size.
|
||||||
let page_size = page_size();
|
let page_size = page_size();
|
||||||
|
@ -136,7 +137,7 @@ fn resize(c: &mut Criterion) {
|
||||||
/// Access current memory map size of the database.
|
/// Access current memory map size of the database.
|
||||||
#[named]
|
#[named]
|
||||||
fn current_map_size(c: &mut Criterion) {
|
fn current_map_size(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
@ -151,7 +152,7 @@ fn current_map_size(c: &mut Criterion) {
|
||||||
/// Access on-disk size of the database.
|
/// Access on-disk size of the database.
|
||||||
#[named]
|
#[named]
|
||||||
fn disk_size_bytes(c: &mut Criterion) {
|
fn disk_size_bytes(c: &mut Criterion) {
|
||||||
let (env, _tempdir) = tmp_concrete_env();
|
let (env, _tempdir) = tmp_env_all_threads();
|
||||||
|
|
||||||
c.bench_function(function_name!(), |b| {
|
c.bench_function(function_name!(), |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
|
25
database/benchmark/benches/service.rs
Normal file
25
database/benchmark/benches/service.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//! `cuprate_database::service` benchmarks.
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
||||||
|
use function_name::named;
|
||||||
|
|
||||||
|
use cuprate_database::{
|
||||||
|
config::Config,
|
||||||
|
resize::{page_size, ResizeAlgorithm},
|
||||||
|
tables::Outputs,
|
||||||
|
ConcreteEnv, Env, EnvInner, TxRo, TxRw,
|
||||||
|
};
|
||||||
|
|
||||||
|
use cuprate_database_benchmark::tmp_env_all_threads;
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Criterion
|
||||||
|
criterion_group! {
|
||||||
|
benches,
|
||||||
|
}
|
||||||
|
criterion_main!(benches);
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------- Benchmarks
|
||||||
|
|
||||||
|
// TODO
|
|
@ -1,4 +1,4 @@
|
||||||
//! TODO
|
//! `trait Storable` benchmarks.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
|
|
@ -11,10 +11,20 @@ use cuprate_database::{config::Config, ConcreteEnv, Env};
|
||||||
///
|
///
|
||||||
/// TODO: changing this to `-> impl Env` causes lifetime errors...
|
/// TODO: changing this to `-> impl Env` causes lifetime errors...
|
||||||
#[allow(clippy::missing_panics_doc)]
|
#[allow(clippy::missing_panics_doc)]
|
||||||
pub fn tmp_concrete_env() -> (ConcreteEnv, tempfile::TempDir) {
|
pub fn tmp_env() -> (ConcreteEnv, tempfile::TempDir) {
|
||||||
let tempdir = tempfile::tempdir().unwrap();
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
let config = Config::low_power(Some(tempdir.path().into()));
|
let config = Config::low_power(Some(tempdir.path().into()));
|
||||||
let env = ConcreteEnv::open(config).unwrap();
|
let env = ConcreteEnv::open(config).unwrap();
|
||||||
|
|
||||||
(env, tempdir)
|
(env, tempdir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Same as [`tmp_env`] but uses all system threads.
|
||||||
|
#[allow(clippy::missing_panics_doc)]
|
||||||
|
pub fn tmp_env_all_threads() -> (ConcreteEnv, tempfile::TempDir) {
|
||||||
|
let tempdir = tempfile::tempdir().unwrap();
|
||||||
|
let config = Config::fast(Some(tempdir.path().into()));
|
||||||
|
let env = ConcreteEnv::open(config).unwrap();
|
||||||
|
|
||||||
|
(env, tempdir)
|
||||||
|
}
|
||||||
|
|
|
@ -80,4 +80,4 @@
|
||||||
#![cfg_attr(debug_assertions, allow(clippy::todo, clippy::multiple_crate_versions))]
|
#![cfg_attr(debug_assertions, allow(clippy::todo, clippy::multiple_crate_versions))]
|
||||||
|
|
||||||
mod helper;
|
mod helper;
|
||||||
pub use helper::tmp_concrete_env;
|
pub use helper::{tmp_env, tmp_env_all_threads};
|
||||||
|
|
Loading…
Reference in a new issue