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]
|
[features]
|
||||||
wasm = ["wasm-bindgen", "js-sys"]
|
wasm = ["wasm-bindgen", "js-sys"]
|
||||||
parallel = []
|
parallel = []
|
||||||
|
mem-prof = []
|
||||||
# whether to use list slice instead of raw str in text container
|
# whether to use list slice instead of raw str in text container
|
||||||
fuzzing = ["crdt-list/fuzzing", "rand", "arbitrary", "tabled"]
|
fuzzing = ["crdt-list/fuzzing", "rand", "arbitrary", "tabled"]
|
||||||
proptest = ["fuzzing"]
|
proptest = ["fuzzing"]
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
// #[global_allocator]
|
// #[global_allocator]
|
||||||
// static GLOBAL: Jemalloc = Jemalloc;
|
// static GLOBAL: Jemalloc = Jemalloc;
|
||||||
|
|
||||||
|
#[cfg(feature = "mem-prof")]
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static ALLOC: dhat::Alloc = dhat::Alloc;
|
static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||||
|
|
||||||
use tikv_jemalloc_ctl::epoch;
|
|
||||||
const RAW_DATA: &[u8; 901823] = include_bytes!("../benches/automerge-paper.json.gz");
|
const RAW_DATA: &[u8; 901823] = include_bytes!("../benches/automerge-paper.json.gz");
|
||||||
|
|
||||||
use std::{io::Read, time::Instant};
|
use std::{io::Read, time::Instant};
|
||||||
|
@ -22,8 +22,8 @@ pub fn main() {
|
||||||
let json: Value = serde_json::from_str(&s).unwrap();
|
let json: Value = serde_json::from_str(&s).unwrap();
|
||||||
drop(s);
|
drop(s);
|
||||||
let txns = json.as_object().unwrap().get("txns");
|
let txns = json.as_object().unwrap().get("txns");
|
||||||
let e = epoch::mib().unwrap();
|
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
#[cfg(feature = "mem-prof")]
|
||||||
let profiler = dhat::Profiler::builder().trim_backtraces(None).build();
|
let profiler = dhat::Profiler::builder().trim_backtraces(None).build();
|
||||||
let mut loro = LoroCore::default();
|
let mut loro = LoroCore::default();
|
||||||
let mut text = loro.get_or_create_root_text("text").unwrap();
|
let mut text = loro.get_or_create_root_text("text").unwrap();
|
||||||
|
@ -53,6 +53,7 @@ pub fn main() {
|
||||||
drop(d);
|
drop(d);
|
||||||
drop(text);
|
drop(text);
|
||||||
loro.debug_inspect();
|
loro.debug_inspect();
|
||||||
|
#[cfg(feature = "mem-prof")]
|
||||||
drop(profiler);
|
drop(profiler);
|
||||||
// e.advance().unwrap();
|
// e.advance().unwrap();
|
||||||
// let new_new_heap = alloc_stats.read().unwrap();
|
// let new_new_heap = alloc_stats.read().unwrap();
|
||||||
|
|
|
@ -31,4 +31,4 @@ bench *FLAGS:
|
||||||
cargo bench --features fuzzing {{FLAGS}}
|
cargo bench --features fuzzing {{FLAGS}}
|
||||||
|
|
||||||
mem:
|
mem:
|
||||||
cargo run --example mem -r --features fuzzing
|
cargo run --example mem -r --features=fuzzing,mem-prof
|
||||||
|
|
Loading…
Reference in a new issue