From cc691bade836d27d02bb2330f0fa323a1d88a1bb Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 7 Nov 2026 22:35:21 +0100 Subject: inspect: the paths changes touch document::inspect: each change's paths read from its operations before it is applied, the same on every node: an object's place as made, cut at lists and text; unknown objects at the root. Auth plan M6. --- src/document/bench.rs | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'src/document/bench.rs') diff --git a/src/document/bench.rs b/src/document/bench.rs index 1bb13ee..bc1f6fa 100644 --- a/src/document/bench.rs +++ b/src/document/bench.rs @@ -25,7 +25,10 @@ //! the change left it (`store::changed_by`, so every node finds the same paths). Against //! receiving a sync message of many changes and loading a document of many changes, as //! above, each change writing a value three levels deep; and decoding alone, the part -//! that grows with the change rather than with its objects. +//! that grows with the change rather than with its objects. Decoded as the document +//! rebuilds them, and from the bytes they came as; and inspected before they are +//! applied (`inspect::Inspector`), their objects made among them or looked up in the +//! document, each once. use std::time::{Duration, Instant}; @@ -509,6 +512,36 @@ fn path_costs(workload: &str, base: Duration, doc: &Document) { } started.elapsed() }); + // Before they are applied (`inspect::Inspector`): those of a sync message to a node + // that has none of them, their objects made among them; those of a document loaded, + // looked up in it. + let inspected = median(3, || { + let empty = Document::new(); + let started = Instant::now(); + let changes: Vec = raw + .iter() + .map(|(_, bytes)| { + automerge::Change::from_bytes(bytes.clone()) + .expect("change") + .decode() + }) + .collect(); + std::hint::black_box(super::inspect::Inspector::new(&empty).paths(&changes)); + started.elapsed() + }); + let looked_up = median(3, || { + let started = Instant::now(); + let changes: Vec = raw + .iter() + .map(|(_, bytes)| { + automerge::Change::from_bytes(bytes.clone()) + .expect("change") + .decode() + }) + .collect(); + std::hint::black_box(super::inspect::Inspector::new(doc).paths(&changes)); + started.elapsed() + }); report_signatures( workload, base, @@ -517,6 +550,8 @@ fn path_costs(workload: &str, base: Duration, doc: &Document) { ("paths", paths), ("from bytes: decoding", decode_bytes), ("paths", paths_bytes), + ("inspected, made among them", inspected), + ("looked up", looked_up), ], ); } -- cgit v1.3.1