mirror of
https://github.com/zh-lx/pinyin-pro.git
synced 2026-03-13 09:51:38 +08:00
14
README.md
14
README.md
@@ -63,14 +63,14 @@ pinyin('汉语拼音', { pattern: 'final' }); // 'àn ǔ īn īn'
|
||||
|
||||
### 性能及准确率
|
||||
|
||||
以下是 `pinyin-pro` 及 `pinyin` 包对于汉字转换的速度及准确率对比,更多细节可以参考
|
||||
以下是 `pinyin-pro`、`pinyin` 及 `@napi-rs/pinyin` 包对于汉字转换的速度及准确率对比,更多细节可以参考
|
||||
|
||||
| 对比项 | pinyin | pinyin-pro |
|
||||
| ------------------- | ---------------- | ---------- |
|
||||
| 准确率 | 95.894% | 99.744% |
|
||||
| 5k 字转换所需时间 | 190.192ms | 7.199ms |
|
||||
| 1w 字转换所需时间 | 内存溢出转换失败 | 13.199ms |
|
||||
| 100w 字转换所需时间 | 内存溢出转换失败 | 646.973ms |
|
||||
| 对比项 | pinyin | pinyin-pro | @napi-rs/pinyin |
|
||||
| ------------------ | ---------------- | ---------- | --------------- |
|
||||
| 准确率 | 97.844% | 99.744% | 97.433% |
|
||||
| 5k 字转换所需时间 | 489.252ms | 5.909ms | 115.723ms |
|
||||
| 1w 字转换所需时间 | 511.573ms | 15.260ms | 115.887ms |
|
||||
| 100w 字转换所需时间 | 内存溢出转换失败 | 595.131ms | 570.994s |
|
||||
|
||||
### 反馈
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,7 @@
|
||||
const { pinyin } = require('../dist');
|
||||
const { pinyin: pinyinPro } = require('../dist');
|
||||
const { pinyin } = require('pinyin');
|
||||
const { pinyin: nApiPinyin } = require('@napi-rs/pinyin');
|
||||
|
||||
|
||||
const text = `
|
||||
序
|
||||
@@ -9533,7 +9536,17 @@ const text = `
|
||||
上面没有名字。但是多年前,有只手用铅笔在上面写了四行诗,在雨露和尘土的洗刷下已渐渐地模糊了,如今可能已经没有了:他安息了。尽管命运多舛,他仍偷生。失去了他的天使他便丧生;事情是自然而然地发生,正如夜幕降临,太阳西沉。
|
||||
`.slice(0, 5000);
|
||||
|
||||
const label = `pinyin-pro 转换 ${text.length} 字数时间`;
|
||||
console.time(label);
|
||||
pinyin(text);
|
||||
console.timeEnd(label);
|
||||
const pinyinProLabel = `pinyin-pro 转换 ${text.length} 字数时间`;
|
||||
console.time(pinyinProLabel);
|
||||
pinyinPro(text);
|
||||
console.timeEnd(pinyinProLabel);
|
||||
|
||||
const pinyinLabel = `pinyin 转换 ${text.length} 字数时间`;
|
||||
console.time(pinyinLabel);
|
||||
pinyin(text, { segment: true });
|
||||
console.timeEnd(pinyinLabel);
|
||||
|
||||
const nApiPinyinLabel = `@napi-rs/pinyin 转换 ${text.length} 字数时间`;
|
||||
console.time(nApiPinyinLabel);
|
||||
nApiPinyin(text, { segment: true });
|
||||
console.timeEnd(nApiPinyinLabel);
|
||||
|
||||
Reference in New Issue
Block a user