fix(bench): correct lines_read to actual successful reads in bench_scroll_rss
lines_read was incorrectly set to max_lines.min(total) (the loop upper bound) instead of the actual number of successfully read lines. Now tracks lines_read via get_line(i).is_some() counter and uses max_lines.min(total) as the correct loop upper bound to handle empty file edge case. Fixes #43
This commit is contained in:
@@ -101,11 +101,15 @@ fn bench_scroll_rss<B: FileReaderBackend>(
|
||||
let sample_interval = 100_000;
|
||||
let max_lines = if config.quick_mode { 100_000 } else { total };
|
||||
|
||||
let upper = max_lines.min(total);
|
||||
let mut rss_samples = Vec::new();
|
||||
let mut hwm_samples = Vec::new();
|
||||
let mut lines_read = 0usize;
|
||||
|
||||
for i in (0..max_lines).step_by(sample_interval) {
|
||||
let _ = reader.get_line(i);
|
||||
for i in (0..upper).step_by(sample_interval) {
|
||||
if reader.get_line(i).is_some() {
|
||||
lines_read += 1;
|
||||
}
|
||||
let rss = MetricsCollector::read_rss();
|
||||
rss_samples.push(rss.vm_rss_kb);
|
||||
hwm_samples.push(rss.vm_hwm_kb);
|
||||
@@ -124,7 +128,7 @@ fn bench_scroll_rss<B: FileReaderBackend>(
|
||||
"max_hwm_kb".into(),
|
||||
hwm_samples.iter().copied().fold(0u64, u64::max) as f64,
|
||||
);
|
||||
extra.insert("lines_read".into(), max_lines.min(total) as f64);
|
||||
extra.insert("lines_read".into(), lines_read as f64);
|
||||
|
||||
reader.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user