Main entry point for the memory benchmark.
()
| 158 | |
| 159 | /// Main entry point for the memory benchmark. |
| 160 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 161 | const ITEM_COUNT: usize = 200_000; |
| 162 | // Approx size: 200k * ~600 bytes = ~120 MB raw data |
| 163 | |
| 164 | let dir = tempdir()?; |
| 165 | let path_parcode_raw = dir.path().join("data_raw.par"); |
| 166 | let path_parcode_lz4 = dir.path().join("data_lz4.par"); |
| 167 | let path_bincode = dir.path().join("data.bin"); |
| 168 | |
| 169 | println!("\n=== PARCODE V3 MEMORY & PERFORMANCE PROFILING ===\n"); |
| 170 | |
| 171 | // 1. SETUP |
| 172 | ALLOCATOR.reset(); |
| 173 | let data = generate_dataset(ITEM_COUNT); |
| 174 | let gen_mem = ALLOCATOR.current(); |
| 175 | println!( |
| 176 | " -> Dataset Memory Footprint: {:.2} MB\n", |
| 177 | gen_mem as f64 / 1024.0 / 1024.0 |
| 178 | ); |
| 179 | |
| 180 | // ------------------------------------------------------------------------ |
| 181 | // PHASE 1: WRITE |
| 182 | // ------------------------------------------------------------------------ |
| 183 | println!("--- PHASE 1: WRITE ---"); |
| 184 | |
| 185 | // A. Parcode (Default / No Compression) |
| 186 | { |
| 187 | ALLOCATOR.reset(); |
| 188 | let start = Instant::now(); |
| 189 | Parcode::save(&path_parcode_raw, &data)?; |
| 190 | let dur = start.elapsed(); |
| 191 | let peak = ALLOCATOR.peak() as f64 / 1_048_576.0; |
| 192 | let size = std::fs::metadata(&path_parcode_raw)?.len() as f64 / 1_048_576.0; |
| 193 | |
| 194 | println!( |
| 195 | "[Parcode Raw] Time: {:.2?}, Peak RAM: {:.2} MB, Disk: {:.2} MB", |
| 196 | dur, peak, size |
| 197 | ); |
| 198 | } |
| 199 | |
| 200 | // B. Parcode (Simulated LZ4 Config via Wrapper) |
| 201 | { |
| 202 | // Wrap the data to force LZ4 injection |
| 203 | let wrapped_data = Lz4Compressed(&data); |
| 204 | |
| 205 | ALLOCATOR.reset(); |
| 206 | let start = Instant::now(); |
| 207 | |
| 208 | // We save the wrapper. The wrapper's visit() forces LZ4 on the Vec. |
| 209 | // Note: Parcode::save takes &T. |
| 210 | Parcode::save(&path_parcode_lz4, &wrapped_data)?; |
| 211 | |
| 212 | let dur = start.elapsed(); |
| 213 | let peak = ALLOCATOR.peak() as f64 / 1_048_576.0; |
| 214 | let size = std::fs::metadata(&path_parcode_lz4)?.len() as f64 / 1_048_576.0; |
| 215 | |
| 216 | println!( |
| 217 | "[Parcode LZ4] Time: {:.2?}, Peak RAM: {:.2} MB, Disk: {:.2} MB", |
nothing calls this directly
no test coverage detected