mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 12:57:20 +00:00
test: add mem-prof feature to test memory
This commit is contained in:
parent
3ea9770871
commit
b5370af5e9
3 changed files with 5 additions and 3 deletions
|
@ -60,6 +60,7 @@ doctest = false
|
|||
[features]
|
||||
wasm = ["wasm-bindgen", "js-sys"]
|
||||
parallel = []
|
||||
mem-prof = []
|
||||
# whether to use list slice instead of raw str in text container
|
||||
fuzzing = ["crdt-list/fuzzing", "rand", "arbitrary", "tabled"]
|
||||
proptest = ["fuzzing"]
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
// #[global_allocator]
|
||||
// static GLOBAL: Jemalloc = Jemalloc;
|
||||
|
||||
#[cfg(feature = "mem-prof")]
|
||||
#[global_allocator]
|
||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||
|
||||
use tikv_jemalloc_ctl::epoch;
|
||||
const RAW_DATA: &[u8; 901823] = include_bytes!("../benches/automerge-paper.json.gz");
|
||||
|
||||
use std::{io::Read, time::Instant};
|
||||
|
@ -22,8 +22,8 @@ pub fn main() {
|
|||
let json: Value = serde_json::from_str(&s).unwrap();
|
||||
drop(s);
|
||||
let txns = json.as_object().unwrap().get("txns");
|
||||
let e = epoch::mib().unwrap();
|
||||
let start = Instant::now();
|
||||
#[cfg(feature = "mem-prof")]
|
||||
let profiler = dhat::Profiler::builder().trim_backtraces(None).build();
|
||||
let mut loro = LoroCore::default();
|
||||
let mut text = loro.get_or_create_root_text("text").unwrap();
|
||||
|
@ -53,6 +53,7 @@ pub fn main() {
|
|||
drop(d);
|
||||
drop(text);
|
||||
loro.debug_inspect();
|
||||
#[cfg(feature = "mem-prof")]
|
||||
drop(profiler);
|
||||
// e.advance().unwrap();
|
||||
// let new_new_heap = alloc_stats.read().unwrap();
|
||||
|
|
|
@ -31,4 +31,4 @@ bench *FLAGS:
|
|||
cargo bench --features fuzzing {{FLAGS}}
|
||||
|
||||
mem:
|
||||
cargo run --example mem -r --features fuzzing
|
||||
cargo run --example mem -r --features=fuzzing,mem-prof
|
||||
|
|
Loading…
Reference in a new issue