var JONG_HANGUL = [
'', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ',
'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ',
'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ',
'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ','ㅎ',
];
JONG_HANGUL['ㅂ'];
JONG_HANGUL.indexOf('ㅂ') !== -1
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
[10]d | |
shshdsh |
Test name | Executions per second |
---|---|
[10]d | 27649322.0 Ops/sec |
shshdsh | 16965024.0 Ops/sec |
I'd be happy to explain what's being tested in this benchmark.
Benchmark Definition
The provided JSON defines two benchmark tests:
JONG_HANGUL['ㅂ'];
- This test measures the execution time of accessing an element at a specific index in the JONG_HANGUL
array.JONG_HANGUL.indexOf('ㅂ') !== -1
- This test measures the execution time of searching for a specific value in the JONG_HANGUL
array using the indexOf()
method.Options Compared
In this benchmark, two options are compared:
a. Direct Indexing: The first test (JONG_HANGUL['ㅂ'];
) directly accesses an element at index 3 of the JONG_HANGUL
array.
b. indexOf() Method: The second test (JONG_HANGUL.indexOf('ㅂ') !== -1
) uses the indexOf()
method to search for the value 'ㅂ'
in the array.
Pros and Cons
indexOf()
method is more flexible and can handle unknown indices or values, making it suitable for dynamic code execution.Library Used
In this benchmark, a custom array JONG_HANGUL
is used. This array appears to contain Unicode characters representing Korean hangul letters.
Other Considerations
Script Preparation Code
section provides a snippet of JavaScript code that initializes the JONG_HANGUL
array.Html Preparation Code
section is empty, indicating that no HTML-related code is being executed in this benchmark.Special JS Feature or Syntax
There doesn't appear to be any special JavaScript feature or syntax used in these benchmarks. However, it's worth noting that the use of Unicode characters like Hangul letters might be specific to a particular context or implementation.
Alternatives
If you were to recreate this benchmark with alternative approaches, some options could include:
Keep in mind that these alternatives would depend on the specific requirements and constraints of the benchmark.