2023-09-05 09:08:41 +00:00
|
|
|
use bench_utils::draw::{gen_draw_actions, DrawAction};
|
|
|
|
use criterion::{criterion_group, criterion_main, Criterion};
|
|
|
|
use loro_internal::LoroDoc;
|
|
|
|
|
|
|
|
pub fn draw(c: &mut Criterion) {
|
|
|
|
let mut data = None;
|
|
|
|
c.bench_function("simulate drawing", |b| {
|
|
|
|
if data.is_none() {
|
|
|
|
data = Some(gen_draw_actions(100, 1000));
|
|
|
|
}
|
|
|
|
|
|
|
|
let mut loro = LoroDoc::new();
|
|
|
|
b.iter(|| {
|
|
|
|
loro = LoroDoc::new();
|
2023-10-29 06:02:13 +00:00
|
|
|
let _paths = loro.get_list("all_paths");
|
|
|
|
let _texts = loro.get_list("all_texts");
|
2023-09-05 09:08:41 +00:00
|
|
|
for action in data.as_ref().unwrap().iter() {
|
|
|
|
match action {
|
2023-10-29 06:02:13 +00:00
|
|
|
DrawAction::DrawPath { points: _, color: _ } => {}
|
2023-09-05 09:08:41 +00:00
|
|
|
DrawAction::Text {
|
2023-10-29 06:02:13 +00:00
|
|
|
id: _,
|
|
|
|
text: _,
|
|
|
|
pos: _,
|
|
|
|
width: _,
|
|
|
|
height: _,
|
2023-09-05 09:08:41 +00:00
|
|
|
} => todo!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
println!("Snapshot size = {}", loro.export_snapshot().len())
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
criterion_group!(benches, draw);
|
|
|
|
criterion_main!(benches);
|