Skip to content

性能基准

Office Oxide 在 6,062 份文件 上做了基准测试 — 来自 11 个独立公开测试集:LibreOffice Core、Apache POI、Open XML SDK、ClosedXML、Pandoc、python-docx/python-pptx、Apache Tika、calamine、openpreserve、oletools、LibreOffice legacy 语料。

方法论:单线程、release 构建带 LTO、温热磁盘缓存(稳态)、闲置系统下 3 次运行的中位数。

DOCX — 2,538 份文件

语言 均值 p99 通过率 许可证
office_oxide Rust 0.8 ms 3.9 ms 98.9% MIT
python-docx Python 11.8 ms 98 ms 95.1% MIT

Office Oxide 比 python-docx 均值快 14 倍、长尾(p99)快 25 倍。通过率高 3.8 个百分点。

XLSX — 1,802 份文件

语言 均值 p99 通过率 许可证
office_oxide Rust 5.0 ms 40 ms 97.8% MIT
python-calamine Rust/Python 13.9 ms 183 ms 96.6% MIT
openpyxl Python 94.5 ms 698 ms 96.2% MIT

Office Oxide 比 calamine 快 2.8 倍(次快的 XLSX 库)、比 openpyxl 快 18 倍。三者中通过率最高。

PPTX — 806 份文件

语言 均值 p99 通过率 许可证
office_oxide Rust 0.7 ms 3.9 ms 98.4% MIT
python-pptx Python 32.5 ms 174 ms 86.7% MIT

Office Oxide 比 python-pptx 快 46 倍、通过率高 11.7 个百分点。python-pptx 在与其期待的 schema 不一致的 PowerPoint 文件上吃力;office_oxide 透明地处理它们。

旧版格式 — 916 份文件

没有其他 Rust 或 Python 库能在不依赖 JVM(Apache Tika)或外部二进制(catdoc、antiword)的情况下读 .doc.xls 以及 .ppt

.doc — 246 份文件

均值 p99 通过率 许可证
office_oxide 0.3 ms 3.4 ms 94.7% MIT
catdoc 4.3 ms 41 ms 90.2% GPL-2.0
antiword 4.5 ms 66 ms 76.8% GPL-2.0

.xls — 494 份文件

均值 p99 通过率 许可证
office_oxide 2.8 ms 75 ms 99.2% MIT
xls2csv (catdoc) 6.9 ms 58 ms 84.0% GPL-2.0
python-calamine 9.0 ms 96 ms 90.7% MIT
xlrd 36.6 ms 503 ms 93.1% BSD-3

xls2csv 的 p99 更紧(58 ms 对 75 ms),但它在复杂 sheet 上输出截断/有损。Office Oxide 均值快 2.4 倍,并且通过率多 15 个百分点。

.ppt — 176 份文件

均值 p99 通过率 许可证
office_oxide 0.7 ms 6.6 ms 100% MIT
catppt (catdoc) 2.8 ms 8 ms 77.8% GPL-2.0

通过率 — 6,062 份文件中达到 98.4%

97 份未通过文件全是无效输入:

类别 数量 备注
无效 ZIP / CFB 归档 43 截断、缺 EOCD、CFB 魔数错
缺必需 part 21 加密、密码保护或 stream 缺失
损坏的 XML 18 XML 炸弹、格式错误标签、模糊测试损坏
无效 CFB 头 15 WordPerfect / IBM DisplayWrite / Excel 3/4 误命名为 .doc/.xls、CVE 利用样本

对合法的 Word 97+ / Excel 97+ / PowerPoint 97+ 零失败。在有效文档上零 panic、零超时、零误判。

语料

来源 文件 许可证
LibreOffice Core 2,185 MPL-2.0
Apache POI 1,298 Apache-2.0
Open XML SDK 707 MIT
ClosedXML 371 MIT
Pandoc 224 GPL-2.0
python-docx + python-pptx 111 MIT
Apache Tika 108 Apache-2.0
calamine 28 MIT
openpreserve 20 CC0
oletools 17 BSD-2
LibreOffice(legacy) 12 MPL-2.0
合计 6,062

可复现基准在 bench_rust/bench_python.py。完整方法和按文件细分见 BENCHMARKS.md

相关链接