parse-pinyin 1.1.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +41 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -110,15 +110,47 @@ console.log(toHanzi('zhong'));
110
110
 
111
111
  ## 性能对比
112
112
 
113
- 在典型的使用场景中,parse-pinyin 相比其他拼音库具有以下优势:
114
-
115
- | 特性 | parse-pinyin | @napi-rs/pinyin |
116
- |------|--------------|-----------------|
117
- | 性能 | 高 | 更高 |
118
- | 依赖 | 无 | 需要原生模块 |
119
- | 包体积 | 小 | 大 |
120
- | 浏览器支持 | 完全支持 | 有限支持 |
121
- | 输出格式 | 多种格式 | 基本格式 |
113
+ 在典型的使用场景中,parse-pinyin 相比其他拼音库具有显著的性能优势:
114
+
115
+ ### pinyin-pro 对比
116
+
117
+ 实际测试结果(硬件:Apple M1 Pro,Node.js v18.17.0):
118
+
119
+ ```javascript
120
+ // 测试代码
121
+ import { toPinyin } from 'parse-pinyin';
122
+ import { pinyin } from 'pinyin-pro';
123
+
124
+ const testChars = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十',
125
+ '中', '国', '人', '民', '大', '家', '好', '学', '习', '天',
126
+ '行', '动', '快', '乐', '幸', '福', '健', '康', '安', '全'];
127
+
128
+ console.time('parse-pinyin');
129
+ for (let i = 0; i < 10000; i++) {
130
+ testChars.forEach(char => {
131
+ toPinyin(char);
132
+ });
133
+ }
134
+ console.timeEnd('parse-pinyin');
135
+ // 输出: parse-pinyin: 13.269ms
136
+
137
+ console.time('pinyin-pro');
138
+ for (let i = 0; i < 10000; i++) {
139
+ testChars.forEach(char => {
140
+ pinyin(char, { toneType: 'symbol' });
141
+ });
142
+ }
143
+ console.timeEnd('pinyin-pro');
144
+ // 输出: pinyin-pro: 166.447ms
145
+ ```
146
+
147
+ ### 性能测试结果
148
+
149
+ | 测试项目 | parse-pinyin | pinyin-pro | 性能提升 |
150
+ |---------|-------------|------------|---------|
151
+ | 单字符拼音转换 (10,000次) | 13.27ms | 166.45ms | 12.54x |
152
+ | 批量处理 (100,000字符) | ~130ms | ~1660ms | 12.77x |
153
+
122
154
 
123
155
  ## 浏览器使用
124
156
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "parse-pinyin",
3
- "version": "1.1.3",
4
- "description": "一个高效的汉字拼音查询库,使用JSON格式存储拼音数据",
3
+ "version": "1.2.4",
4
+ "description": "一个高效的汉字拼音查询库,兼容浏览器和nodejs,提供ESM、commonjs、iife格式的构建,支持拼音反查",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",