Skip to content

Commit f8f3edc

Browse files
committed
Add cross-runtime streaming query stress test support
1 parent 3854255 commit f8f3edc

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ cargo add miniexcel
1818

1919
MiniExcel requires Rust 1.85.0 or later.
2020

21+
## Rust and .NET Stress Test
22+
23+
Keep `MiniExcel-Rust` and the [.NET MiniExcel repository](https://github.com/mini-software/MiniExcel) in sibling directories, then run the shared stress harness from the .NET repository:
24+
25+
```powershell
26+
pwsh ./benchmarks/compare-rust-dotnet.ps1
27+
```
28+
29+
This benchmark compares dynamic streaming Query performance: Rust uses `MiniExcel::query`, and .NET uses `OpenXmlImporter.Query`. Save performance is not included. Both implementations stream the same 100,000-row XLSX workbook. The harness verifies matching row counts and reports elapsed time and peak working set over repeated runs. Results vary by environment, so compare values produced on the same machine.
30+
2131
## Features
2232

2333
- Bounded-memory dynamic and typed worksheet streaming.

‎README.zh-CN.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ cargo add miniexcel
1818

1919
MiniExcel 最低支持 Rust 1.85.0。
2020

21+
## Rust 与 .NET 压力测试
22+
23+
将 `MiniExcel-Rust` 与 [.NET MiniExcel 仓库](https://github.com/mini-software/MiniExcel) 放在同级目录,然后从 .NET 仓库运行共用压力测试脚本:
24+
25+
```powershell
26+
pwsh ./benchmarks/compare-rust-dotnet.ps1
27+
```
28+
29+
本测试比较动态流式 Query 性能:Rust 使用 `MiniExcel::query`,.NET 使用 `OpenXmlImporter.Query`,不包含 Save 性能。两种实现会流式读取同一份 100,000 行 XLSX 工作簿。脚本将校验读取行数一致,并报告多轮测试的耗时和峰值工作集。测试结果受运行环境影响,应以同一台机器产生的数据进行比较。
30+
2131
## 功能
2232

2333
- 以有界内存流式读取动态行和类型化行。

‎miniexcel/examples/stress_query.rs‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use std::env;
2+
use std::error::Error;
3+
use std::io;
4+
5+
use miniexcel::MiniExcel;
6+
7+
fn main() -> Result<(), Box<dyn Error>> {
8+
let mut args = env::args_os().skip(1);
9+
let path = args.next().ok_or_else(|| {
10+
io::Error::new(io::ErrorKind::InvalidInput, "usage: stress_query <xlsx-path> [passes]")
11+
})?;
12+
let passes =
13+
args.next().map(|value| value.to_string_lossy().parse::<usize>()).transpose()?.unwrap_or(1);
14+
15+
if passes == 0 || args.next().is_some() {
16+
return Err(io::Error::new(
17+
io::ErrorKind::InvalidInput,
18+
"usage: stress_query <xlsx-path> [passes]",
19+
)
20+
.into());
21+
}
22+
23+
let mut row_count = 0_u64;
24+
for _ in 0..passes {
25+
for row in MiniExcel::query(&path)? {
26+
let _ = row?;
27+
row_count += 1;
28+
}
29+
}
30+
31+
println!("{row_count}");
32+
Ok(())
33+
}

0 commit comments

Comments
 (0)