global: snapshot

This commit is contained in:
nym21
2026-01-12 22:43:56 +01:00
parent b675b70067
commit 5ffb66c0dc
39 changed files with 8207 additions and 11957 deletions

View File

@@ -1,10 +1,10 @@
use std::{env, path::Path, thread};
use std::{env, path::Path, thread, time::Instant};
use brk_computer::Computer;
use brk_error::Result;
use brk_fetcher::Fetcher;
use brk_indexer::Indexer;
use vecdb::{AnyStoredVec, Exit};
use vecdb::{AnySerializableVec, AnyVec, Exit};
pub fn main() -> Result<()> {
// Can't increase main thread's stack size, thus we need to use another thread
@@ -19,7 +19,6 @@ fn run() -> Result<()> {
brk_logger::init(None)?;
let outputs_dir = Path::new(&env::var("HOME").unwrap()).join(".brk");
// let outputs_dir = Path::new("../../_outputs");
let indexer = Indexer::forced_import(&outputs_dir)?;
@@ -30,7 +29,35 @@ fn run() -> Result<()> {
let computer = Computer::forced_import(&outputs_dir, &indexer, Some(fetcher))?;
let _a = dbg!(computer.transactions.fees.fee.base.region().meta());
// Test emptyaddressdata (underlying BytesVec) - direct access
let empty_data = &computer.distribution.addresses_data.empty;
println!("emptyaddressdata (BytesVec) len: {}", empty_data.len());
let start = Instant::now();
let mut buf = Vec::new();
empty_data.write_json(Some(empty_data.len() - 1), Some(empty_data.len()), &mut buf)?;
println!("emptyaddressdata last item JSON: {}", String::from_utf8_lossy(&buf));
println!("Time for BytesVec write_json: {:?}", start.elapsed());
// Test emptyaddressindex (LazyVecFrom1 wrapper) - computed access
let empty_index = &computer.distribution.emptyaddressindex;
println!("\nemptyaddressindex (LazyVecFrom1) len: {}", empty_index.len());
let start = Instant::now();
let mut buf = Vec::new();
empty_index.write_json(Some(empty_index.len() - 1), Some(empty_index.len()), &mut buf)?;
println!("emptyaddressindex last item JSON: {}", String::from_utf8_lossy(&buf));
println!("Time for LazyVecFrom1 write_json: {:?}", start.elapsed());
// Compare with loaded versions
let loaded_data = &computer.distribution.addresses_data.loaded;
println!("\nloadedaddressdata (BytesVec) len: {}", loaded_data.len());
let start = Instant::now();
let mut buf = Vec::new();
loaded_data.write_json(Some(loaded_data.len() - 1), Some(loaded_data.len()), &mut buf)?;
println!("loadedaddressdata last item JSON: {}", String::from_utf8_lossy(&buf));
println!("Time for BytesVec write_json: {:?}", start.elapsed());
Ok(())
}