diff --git a/benchmarks/package.json b/benchmarks/package.json index e95efbd3..404da878 100644 --- a/benchmarks/package.json +++ b/benchmarks/package.json @@ -10,11 +10,9 @@ "es-hangul": "workspace:^", "esbuild": "0.23.0", "josa": "^3.0.1", - "k-popo": "^2.0.5", "vitest": "^2.1.2" }, "devDependencies": { "@types/josa": "^3" - }, - "version": null + } } diff --git a/benchmarks/performance/josa.bench.ts b/benchmarks/performance/josa.bench.ts index 8afcf706..082b3c73 100644 --- a/benchmarks/performance/josa.bench.ts +++ b/benchmarks/performance/josa.bench.ts @@ -3,7 +3,6 @@ import { fakerKO as faker } from '@faker-js/faker'; import { josa as autoJosa } from 'auto-josa'; import { josa as esHangulJosa } from 'es-hangul'; import { josa } from 'josa'; -import { ko } from 'k-popo'; import { bench, describe } from 'vitest'; const name = faker.person.firstName(); @@ -20,10 +19,6 @@ describe('하나의 조사', () => { bench('josa', () => { josa(`${name}#{이}`); }); - - bench('k-popo', () => { - ko`${name}(이)가`; - }); }); const city = faker.location.city(); @@ -51,11 +46,4 @@ describe(`네개의 조사 ${name}이/가 ${noun}을/를 ${city}은/는 ${street josa(`${city}#{은}`); josa(`${street}#{와}`); }); - - bench('k-popo', () => { - ko`${noun}(이)가`; - ko`${name}(을)를`; - ko`${city}(은)는`; - ko`${street}(와)과`; - }); }); diff --git a/docs/src/pages/docs/introduction.en.mdx b/docs/src/pages/docs/introduction.en.mdx index 24d92c51..32481de2 100644 --- a/docs/src/pages/docs/introduction.en.mdx +++ b/docs/src/pages/docs/introduction.en.mdx @@ -81,6 +81,13 @@ const sentence2 = josa(word2, '이/가') + ' 맛있습니다.'; console.log(sentence2); // '바나나가 맛있습니다.' ``` +### Fast + + +es-hangul boasts **top-notch performance**, efficiently handling complex tasks such as Korean character composition and decomposition with incredible speed. +[Benchmark tests]('./technical/benchmark') against other libraries have shown that es-hangul delivers **overwhelmingly superior performance**. + + If you have a good idea for handling Hangul well, please let us know. [Suggest a feature via GitHub Issue](https://github.com/toss/es-hangul/issues/new?assignees=&labels=feature&projects=&template=feature_request.yml&title=%5BFeature%5D%3A) diff --git a/docs/src/pages/docs/introduction.ko.mdx b/docs/src/pages/docs/introduction.ko.mdx index f78fbed1..1225f855 100644 --- a/docs/src/pages/docs/introduction.ko.mdx +++ b/docs/src/pages/docs/introduction.ko.mdx @@ -80,6 +80,14 @@ const sentence2 = josa(word2, '이/가') + ' 맛있습니다.'; console.log(sentence2); // '바나나가 맛있습니다.' ``` + +### 매우 빠릅니다 + +`es-hangul`은 **한글 조합** 및 **분해** 같은 복잡한 작업을 놀라운 속도로 수행하는 **최고의 성능**을 자랑합니다.
+다른 라이브러리와의 [벤치마크](./technical/benchmark) 테스트 결과, `es-hangul`이 **압도적으로 빠른 성능**을 보여주었습니다 + + + 한글을 잘 다루기 위한 좋은 아이디어가 있다면 알려주세요. [GitHub Issue로 기능 제안하기](https://github.com/toss/es-hangul/issues/new?assignees=&labels=feature&projects=&template=feature_request.yml&title=%5BFeature%5D%3A) diff --git a/docs/src/pages/docs/technical/benchmark-bar-chart.tsx b/docs/src/pages/docs/technical/benchmark-bar-chart.tsx new file mode 100644 index 00000000..5255cc99 --- /dev/null +++ b/docs/src/pages/docs/technical/benchmark-bar-chart.tsx @@ -0,0 +1,143 @@ +import { useEffect, useRef, useState } from 'react'; + +const ANIMATION_THRESHOLD = 0.3; + +interface BenchmarkBarChart { + locale: 'ko' | 'en'; +} + +export const BenchmarkBarChart = ({ locale }: BenchmarkBarChart) => { + const [filledPercentages, setFilledPercentages] = useState(benchmarkData.map(() => 0)); + const [isVisible, setIsVisible] = useState(false); + const chartRef = useRef(null); + + useEffect(() => { + const observer = new IntersectionObserver( + ([entry]) => { + if (entry.intersectionRatio >= ANIMATION_THRESHOLD) { + setIsVisible(true); + } + }, + { threshold: ANIMATION_THRESHOLD } + ); + + if (chartRef.current) { + observer.observe(chartRef.current); + } + + return () => { + if (chartRef.current) { + observer.unobserve(chartRef.current); + } + }; + }, []); + + useEffect(() => { + const maximum = Math.max(...benchmarkData.map(data => data.operationsPerSecond)); + + if (isVisible) { + setFilledPercentages(benchmarkData.map(data => (data.operationsPerSecond / maximum) * 100)); + } + }, [isVisible]); + + const isKorean = locale === 'ko'; + + return ( +
+

+ Lightning Fast +

+ +
+ {benchmarkData.map((data, index) => ( +
+
+ + {data.name} + + + {data.name === 'es-hangul' && ( + fastest // status는 es-hangul에만 표시 + )} +
+
+
+
+
+ {isKorean ? ( + <> + 작업 처리량: {data.operationsPerSecond.toLocaleString()} ops/sec + 1000만 건 처리 시간: {data.timeToProcess}초 + + ) : ( + <> + Throughput: {data.operationsPerSecond.toLocaleString()} ops/sec + Processing time for 10 million records: {data.timeToProcess} seconds + + )} +
+
+ ))} +
+

+ {isKorean ? '* josa 함수를 기준으로 측정하였습니다.' : '* Measurements were based on the `josa` function.'} +

+ + + + + {isKorean ? '더 자세한 벤치마크 결과 보기' : 'See more detailed benchmark results'} + + +
+ ); +}; + +const 천만 = 10000000; +const benchmarkData = [ + { + name: 'es-hangul', + operationsPerSecond: 11199038, + timeToProcess: (천만 / 11199038).toFixed(2), + status: 'fastest', + }, + { + name: 'auto-josa', + operationsPerSecond: 8512551, + timeToProcess: (천만 / 8512551).toFixed(2), + }, + { + name: 'josa', + operationsPerSecond: 3334947, + timeToProcess: (천만 / 3334947).toFixed(2), + }, +]; diff --git a/docs/src/pages/docs/technical/benchmark.en.mdx b/docs/src/pages/docs/technical/benchmark.en.mdx new file mode 100644 index 00000000..fa8b7cb9 --- /dev/null +++ b/docs/src/pages/docs/technical/benchmark.en.mdx @@ -0,0 +1,17 @@ +--- +title: benchamark +--- + +import { BenchmarkBarChart } from './benchmark-bar-chart.tsx'; + + +# ⚡ Fast Korean Text Processing Library + + +es-hangul boasts **top-notch performance**, efficiently handling complex tasks such as Korean character composition and decomposition with incredible speed. +Benchmark tests against other libraries have shown that es-hangul delivers **overwhelmingly superior performance**. + +
+
+ + diff --git a/docs/src/pages/docs/technical/benchmark.ko.mdx b/docs/src/pages/docs/technical/benchmark.ko.mdx new file mode 100644 index 00000000..e2935929 --- /dev/null +++ b/docs/src/pages/docs/technical/benchmark.ko.mdx @@ -0,0 +1,16 @@ +--- +title: benchamark +--- + +import { BenchmarkBarChart } from './benchmark-bar-chart.tsx'; + + +# ⚡ 빠른 한글 처리 라이브러리 + +`es-hangul`은 **한글 조합** 및 **분해** 같은 복잡한 작업을 놀라운 속도로 수행하는 **최고의 성능**을 자랑합니다.
+다른 라이브러리와의 벤치마크 테스트 결과, `es-hangul`이 **압도적으로 빠른 성능**을 보여주었습니다 + +
+
+ + diff --git a/yarn.lock b/yarn.lock index 51d0f348..c50ee927 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3650,7 +3650,6 @@ __metadata: es-hangul: "workspace:^" esbuild: "npm:0.23.0" josa: "npm:^3.0.1" - k-popo: "npm:^2.0.5" vitest: "npm:^2.1.2" languageName: unknown linkType: soft @@ -8326,13 +8325,6 @@ __metadata: languageName: node linkType: hard -"k-popo@npm:^2.0.5": - version: 2.0.5 - resolution: "k-popo@npm:2.0.5" - checksum: 10c0/00e0e84bf04edf5cd61859891c210ed82b5cacc4546dc7302bb708a7409d648b38814ec3b791c2994ccf3f23285e1c88622af0d21614d39b4667a3d49640ba62 - languageName: node - linkType: hard - "katex@npm:^0.16.0, katex@npm:^0.16.9": version: 0.16.10 resolution: "katex@npm:0.16.10"