Files
nanoreth/crates/libmdbx-rs/benches/utils.rs
rakita 8ac5214fc6 chore(libmbx): fmt, clippy and deny list updated (#134)
* feat(db): Add mdbx-rs apache licenced code 55e234

* feat(db): replace mdbx with reth-mdbx, metadata changes

* chore(db): bump mdbx-sys to 0.12.1

* remove libmdbx from cargo deny

* cargo fmt

* cargo clippy

* one more clippy error
2022-10-25 03:18:51 -07:00

26 lines
666 B
Rust

use reth_libmdbx::{Environment, NoWriteMap, WriteFlags};
use tempfile::{tempdir, TempDir};
pub fn get_key(n: u32) -> String {
format!("key{}", n)
}
pub fn get_data(n: u32) -> String {
format!("data{}", n)
}
pub fn setup_bench_db(num_rows: u32) -> (TempDir, Environment<NoWriteMap>) {
let dir = tempdir().unwrap();
let env = Environment::new().open(dir.path()).unwrap();
{
let txn = env.begin_rw_txn().unwrap();
let db = txn.open_db(None).unwrap();
for i in 0..num_rows {
txn.put(&db, &get_key(i), &get_data(i), WriteFlags::empty()).unwrap();
}
txn.commit().unwrap();
}
(dir, env)
}