You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve runtime perf on the Unicode text processing.
6
+
7
+
By using a precomputed lookup table for the grapheme categries of BMP characters, it improves perf by more than 10% for common cases, even ~30% for some extream cases.
8
+
9
+
The lookup table consumes an additional 64 KB of memory, which is acceptable for most JavaScript runtime environments.
10
+
11
+
This optimization is introduced by OpenCode w/ OpenAI's GPT-OSS-120B. It is the second successful attempt at meaningful optimization in this library.
12
+
(The first one was the Claude Code w/ Claude Opus 4.0)
@@ -246,16 +246,16 @@ Since [Hermes doesn't support the `Intl.Segmenter` API](https://github.com/faceb
246
246
247
247
Here is a brief explanation, and you can see [archived benchmark results](benchmark/grapheme/_records).
248
248
249
-
**Performance in Node.js**: `unicode-segmenter/grapheme`is significantly faster than alternatives.
250
-
-6\~15x faster than other JavaScript libraries
251
-
-1.5\~3x faster than WASM binding of the Rust's [unicode-segmentation]
252
-
-1.5\~3x faster than built-in [`Intl.Segmenter`]
249
+
**Performance in Node.js/Bun/Deno**: `unicode-segmenter/grapheme`has best-in-class performance.
250
+
-8\~35x faster than other JavaScript libraries.
251
+
-3\~5x faster than WASM binding of the Rust's [unicode-segmentation].
252
+
-2\~3x faster than built-in [`Intl.Segmenter`].
253
253
254
-
**Performance in Bun**: `unicode-segmenter/grapheme` has almost the same performance as the built-in [`Intl.Segmenter`], with no performance degradation compared to other JavaScript libraries.
254
+
**Performance in Browsers**: The performance in browser environments varies greatly due to differences in browser engines, which makes benchmarking inconsistent, but:
255
+
- Still significantly faster than other JavaScript libraries.
256
+
- Generally outperforms the built-in in the most browser environments, except the Firefox.
255
257
256
-
**Performance in Browsers**: The performance in browser environments varies greatly due to differences in browser engines and versions, which makes benchmarking less consistent. Despite these variations, `unicode-segmenter/grapheme` generally outperforms other JavaScript libraries in most environments.
257
-
258
-
**Performance in React Native**: `unicode-segmenter/grapheme` is significantly faster than alternatives when compiled to Hermes bytecode. It's 3\~8x faster than `graphemer` and 20\~26x faster than `grapheme-splitter`, with the performance gap increasing with input size.
258
+
**Performance in React Native**: `unicode-segmenter/grapheme` is still faster than alternatives when compiled to Hermes bytecode. It's 3\~8x faster than `graphemer` and 20\~26x faster than `grapheme-splitter`, with the performance gap increasing with input size.
259
259
260
260
**Performance in QuickJS**: `unicode-segmenter/grapheme` is the only usable library in terms of performance.
0 commit comments