Repository navigation
Add BenchmarkDotNet harness: fork vs upstream jieba.NET 0.42.2 - #5
Merged
Merged
Conversation
Member
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
新增 BenchmarkDotNet 性能对比套件,用于持续对比本仓库(fork)与 NuGet 上游 jieba.NET 0.42.2,方便后续优化量化验证。
布局
benchmark/Shared/BenchSuite.cs:共享套件——12 个场景(精确/无HMM/全模式/搜索引擎 × 短句/medium/大文本、词性标注、TF-IDF、TextRank)+ 冷启动;两个项目各自只引用一个实现(类型同名,无法单项目共存)。benchmark/JiebaNet.ForkBench:引用本仓库源码(net10.0 资产,内嵌资源 + STJ)。benchmark/JiebaNet.UpstreamBench:引用 NuGet 包jieba.NET 0.42.2,并自动将仓库Resources/词典复制到输出目录(上游从磁盘加载),保证数据一致。benchmark/run.ps1:一键脚本——串行构建并运行双方(避免 CPU 争抢)、打印 BDN 原始表格、各测 3 次冷启动、最后输出按场景合并的对比表(upstream / fork> 1 表示 fork 更快)。使用
一次性运行结论(i9-10900KF / .NET 10.0.9 / ShortRun)
fork 全面小幅占优:分词路径 1.07x~1.30x(TF-IDF 1.52x、TextRank 1.42x),词性标注持平(0.97x);内存分配两边几乎一致;冷启动 ~375ms vs ~490ms(fork 且无文件依赖)。ShortRun 误差棒较宽,结论以方向为准。
其它
/benchmark/文件夹,CI 会持续验证其可编译。benchmark/README.md。