让分钟行情按流式迭代器处理

This commit is contained in:
boris
2026-08-27 13:25:28 +08:00
parent ed126a3630
commit c86a0e2339
3 changed files with 137 additions and 45 deletions
@@ -177,3 +177,46 @@ fn benchmark_bounded_intraday_history() {
elapsed.as_secs_f64(),
);
}
#[test]
#[ignore = "manual release-mode quote-stream benchmark"]
fn benchmark_borrowed_execution_quote_stream() {
let (data, dates) = dataset(250, 240);
let date = *dates.last().expect("last date");
let symbols = std::collections::BTreeSet::from([SYMBOL.to_string()]);
for _ in 0..5 {
black_box(data.execution_quotes_on_date_for_symbols(date, Some(&symbols)));
black_box(
data.execution_quotes_iter_on_date_for_symbols(date, Some(&symbols))
.count(),
);
}
let materialized_started = Instant::now();
let mut materialized_checksum = 0_i64;
for _ in 0..5_000 {
let rows = data.execution_quotes_on_date_for_symbols(date, Some(&symbols));
materialized_checksum += rows
.iter()
.map(|quote| quote.timestamp.and_utc().timestamp())
.sum::<i64>();
black_box(rows);
}
let materialized_seconds = materialized_started.elapsed().as_secs_f64();
let streamed_started = Instant::now();
let mut streamed_checksum = 0_i64;
for _ in 0..5_000 {
let count = data
.execution_quotes_iter_on_date_for_symbols(date, Some(&symbols))
.map(|quote| quote.timestamp.and_utc().timestamp())
.sum::<i64>();
streamed_checksum += count;
black_box(count);
}
let streamed_seconds = streamed_started.elapsed().as_secs_f64();
eprintln!(
"quote_stream_benchmark iterations=5000 rows_per_day=240 materialized_seconds={materialized_seconds:.6} streamed_seconds={streamed_seconds:.6} materialized_checksum={materialized_checksum} streamed_checksum={streamed_checksum}"
);
}