var JONG_HANGUL = [
'', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ',
'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ',
'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ',
'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ','ㅎ',
];
({
"": 0,
"ㄱ": 1,
"ㄲ": 2,
"ㄳ": 3,
"ㄴ": 4,
"ㄵ": 5,
"ㄶ": 6,
"ㄷ": 7,
"ㄹ": 8,
"ㄺ": 9,
"ㄻ": 10,
"ㄼ": 11,
"ㄽ": 12,
"ㄾ": 13,
"ㄿ": 14,
"ㅀ": 15,
"ㅁ": 16,
"ㅂ": 17,
"ㅄ": 18,
"ㅅ": 19,
"ㅆ": 20,
"ㅇ": 21,
"ㅈ": 22,
"ㅊ": 23,
"ㅋ": 24,
"ㅌ": 25,
"ㅍ": 26,
"ㅎ": 27
})['ㅂ'];
JONG_HANGUL.indexOf('ㅂ') !== -1
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
[10]d | |
shshdsh |
Test name | Executions per second |
---|---|
[10]d | 951340416.0 Ops/sec |
shshdsh | 17631274.0 Ops/sec |
Benchmark Overview
The provided benchmark is designed to measure the performance of JavaScript's string operations, specifically looking at the indexing and searching capabilities of strings.
Options Compared
There are two test cases:
dfjf2hdshsdrh
: This test case measures the time it takes to access an element in a large object using bracket notation (object[key]
).shshdsh
: This test case measures the time it takes for the browser's indexOf
method to find a specific character within a Unicode string.Pros and Cons
[]
)indexOf
MethodLibrary and Syntax
In the dfjf2hdshsdrh
test case, there is no explicit library mentioned. However, it appears to use a custom object with Unicode characters as keys. The script preparation code defines an array (JONG_HANGUL
) containing Unicode characters, which is then used in the benchmark.
The shshdsh
test case uses the browser's built-in indexOf
method, which is a standard JavaScript API.
Special JS Features or Syntax
There are no special JavaScript features or syntax mentioned in this benchmark.
Other Alternatives
For similar benchmarks, you might consider:
slice
, substring
, or replace
.Keep in mind that the choice of benchmark and options will depend on the specific requirements and goals of your project.
Benchmark Preparation Code
The script preparation code defines an array JONG_HANGUL
containing Unicode characters:
var JONG_HANGUL = [
'',
'ㄱ',
'ㄲ',
'ㄳ',
'ㄴ',
'ㄵ',
'ㄶ',
'ㄷ',
'ㄹ',
'ㄺ',
'ㄻ',
'ㄼ',
'ㄽ',
'ㄾ',
'ㄿ',
'ㅀ',
'ㅁ',
'ㅂ',
'ㅄ',
'ㅅ',
'ㅆ',
'ㅇ',
'ㅈ',
'ㅊ',
'ㅋ',
'ㅌ',
'ㅍ',
'ㅎ'
];
This array is used in the dfjf2hdshsdrh
test case to create a large object with Unicode characters as keys.