13af6ab5fSopenharmony_ci# es2abc-benchmark
23af6ab5fSopenharmony_ci
33af6ab5fSopenharmony_ci## Project Description
43af6ab5fSopenharmony_ciThe purpose of this project is to test the performance of es2abc when compiling JS and output a report of the test results.  
53af6ab5fSopenharmony_ciThis tool relies on Python3, Git, and the es2abc executable file under the ets_frontend component.  
63af6ab5fSopenharmony_ciBy default, test cases are stored in the 'test_cases' directory, and run results are stored in the 'output' directory.  
73af6ab5fSopenharmony_ci## Usage notes
83af6ab5fSopenharmony_ci#### Parameter description
93af6ab5fSopenharmony_ci|   Parameter   |                         Description                          |  Type   |            Default Value            |
103af6ab5fSopenharmony_ci| :-----------: | :----------------------------------------------------------: | :-----: | :---------------------------------: |
113af6ab5fSopenharmony_ci| --es2abc-tool | This parameter is required and requires a path to the es2abc tool to be provided. | string  |                 N/A                 |
123af6ab5fSopenharmony_ci|    --runs     | This parameter is optional and the default value is 20. Represents the number of times a use case was executed in a test. |   int   |                 20                  |
133af6ab5fSopenharmony_ci|  --opt-level  | This parameter is optional and specifies the optimization level of the compiler. | string  |                  0                  |
143af6ab5fSopenharmony_ci| --parse-only  | This parameter is optional and the default value is False. If set to True, only the input file will be parsed during testing. | boolean |                False                |
153af6ab5fSopenharmony_ci| --engine-comp  | This parameter is optional, and the default value is False. At this time, only the es2abc test is performed. When it is True, it is compared with the Hermes engine. | boolean |                False                |
163af6ab5fSopenharmony_ci
173af6ab5fSopenharmony_ci#### Description of the test case
183af6ab5fSopenharmony_ci    The test suite and test cases for this project are sourced from open source libraries:
193af6ab5fSopenharmony_ci#### Test Suite:
203af6ab5fSopenharmony_ci  | name |                                                                                                            description                                                                                                            | GitHub address |
213af6ab5fSopenharmony_ci  | :--: |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| :--: |
223af6ab5fSopenharmony_ci  | Octane |                                                          JavaScript benchmarking suite for evaluating the performance of browsers in handling complex JavaScript tasks.                                                           | [https://github.com/chromium/octane](https://github.com/chromium/octane) |
233af6ab5fSopenharmony_ci  | Kraken |                                     JavaScript performance test suite, including a series of test cases covering dynamic scenarios, garbage collection, encryption, and graphics operations.                                      | [https://github.com/mozilla/krakenbenchmark.mozilla.org](https://github.com/mozilla/krakenbenchmark.mozilla.org) |
243af6ab5fSopenharmony_ci  | SunSpider |                                                     JavaScript performance testing suite, used to evaluate the performance of JavaScript engines in performing common tasks.                                                      | [https://github.com/mozilla/krakenbenchmark.mozilla.org](https://github.com/mozilla/krakenbenchmark.mozilla.org) |
253af6ab5fSopenharmony_ci#### Comparison Engine
263af6ab5fSopenharmony_ci    When running this benchmark, you can compare the performance of es2abc compilation with that of Hermes compilation. Hermes engine GitHub address: https://github.com/facebook/hermes
273af6ab5fSopenharmony_ci
283af6ab5fSopenharmony_ci#### Run an example
293af6ab5fSopenharmony_ciThe script runtime depends on the es2abc executable after the ets_frontend component is compiled. es2abc compilation command:
303af6ab5fSopenharmony_ci```
313af6ab5fSopenharmony_ci$ ./build.sh --product-name rk3568 --build-target ets_frontend_build
323af6ab5fSopenharmony_ci```
333af6ab5fSopenharmony_ciSpecify the es2abc executable and run the 'run_benchmark.py' for testing:
343af6ab5fSopenharmony_ci```
353af6ab5fSopenharmony_ci$ python3 run_benchmark.py --es2abc-tool  /out/xx/xx/xx/ets_frontend/es2abc
363af6ab5fSopenharmony_ci```
373af6ab5fSopenharmony_ciCompare with Hermes Engine:
383af6ab5fSopenharmony_ci```
393af6ab5fSopenharmony_ci$ python3 run_benchmark.py --es2abc-tool  /out/xx/xx/xx/ets_frontend/es2abc --engine-comp
403af6ab5fSopenharmony_ci```
413af6ab5fSopenharmony_ciSpecify the number of rounds of test case compilation (20 rounds by default):
423af6ab5fSopenharmony_ci```
433af6ab5fSopenharmony_ci$ python3 run_benchmark.py --es2abc-tool  /out/xx/xx/xx/ets_frontend/es2abc --runs 10  // It can be modified to the required number of compilation rounds
443af6ab5fSopenharmony_ci```
453af6ab5fSopenharmony_ci--parse-only only parses the test case, and when the --engine-comp parameter is used, this parameter is invalid:
463af6ab5fSopenharmony_ci```
473af6ab5fSopenharmony_ci$  python3 run_benchmark.py --es2abc-tool  /out/xx/xx/xx/ets_frontend/es2abc --parse-only
483af6ab5fSopenharmony_ci```
493af6ab5fSopenharmony_ci--opt-level specifies the compilation optimization level, and when the --engine-comp parameter is used, this parameter is invalid:
503af6ab5fSopenharmony_ci```
513af6ab5fSopenharmony_ci$  python3 run_benchmark.py --es2abc-tool  /out/xx/xx/xx/ets_frontend/es2abc --opt-level '2'
523af6ab5fSopenharmony_ci```
533af6ab5fSopenharmony_ciThe generated test results are stored in the 'output' directory, and the command line prints basic test information, such as:
543af6ab5fSopenharmony_ci
553af6ab5fSopenharmony_ci```plain
563af6ab5fSopenharmony_ci> > > benchmark running
573af6ab5fSopenharmony_ciRunning navier-stokes....
583af6ab5fSopenharmony_ciRunning typescript....
593af6ab5fSopenharmony_ciRunning mandreel....
603af6ab5fSopenharmony_ci```
613af6ab5fSopenharmony_ci### Precautions
623af6ab5fSopenharmony_ci    This tool relies on ets_frontend components to compile the es2abc executable file. and you need to specify the es2abc path when using it.
633af6ab5fSopenharmony_ci    The test cases for this tool are open source cases, and the test suite is automatically pulled during run time.
643af6ab5fSopenharmony_ci
65