1# es2abc-benchmark 2 3## Project Description 4The purpose of this project is to test the performance of es2abc when compiling JS and output a report of the test results. 5This tool relies on Python3, Git, and the es2abc executable file under the ets_frontend component. 6By default, test cases are stored in the 'test_cases' directory, and run results are stored in the 'output' directory. 7## Usage notes 8#### Parameter description 9| Parameter | Description | Type | Default Value | 10| :-----------: | :----------------------------------------------------------: | :-----: | :---------------------------------: | 11| --es2abc-tool | This parameter is required and requires a path to the es2abc tool to be provided. | string | N/A | 12| --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 | 13| --opt-level | This parameter is optional and specifies the optimization level of the compiler. | string | 0 | 14| --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 | 15| --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 | 16 17#### Description of the test case 18 The test suite and test cases for this project are sourced from open source libraries: 19#### Test Suite: 20 | name | description | GitHub address | 21 | :--: |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| :--: | 22 | 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) | 23 | 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) | 24 | 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) | 25#### Comparison Engine 26 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 27 28#### Run an example 29The script runtime depends on the es2abc executable after the ets_frontend component is compiled. es2abc compilation command: 30``` 31$ ./build.sh --product-name rk3568 --build-target ets_frontend_build 32``` 33Specify the es2abc executable and run the 'run_benchmark.py' for testing: 34``` 35$ python3 run_benchmark.py --es2abc-tool /out/xx/xx/xx/ets_frontend/es2abc 36``` 37Compare with Hermes Engine: 38``` 39$ python3 run_benchmark.py --es2abc-tool /out/xx/xx/xx/ets_frontend/es2abc --engine-comp 40``` 41Specify the number of rounds of test case compilation (20 rounds by default): 42``` 43$ 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 44``` 45--parse-only only parses the test case, and when the --engine-comp parameter is used, this parameter is invalid: 46``` 47$ python3 run_benchmark.py --es2abc-tool /out/xx/xx/xx/ets_frontend/es2abc --parse-only 48``` 49--opt-level specifies the compilation optimization level, and when the --engine-comp parameter is used, this parameter is invalid: 50``` 51$ python3 run_benchmark.py --es2abc-tool /out/xx/xx/xx/ets_frontend/es2abc --opt-level '2' 52``` 53The generated test results are stored in the 'output' directory, and the command line prints basic test information, such as: 54 55```plain 56> > > benchmark running 57Running navier-stokes.... 58Running typescript.... 59Running mandreel.... 60``` 61### Precautions 62 This tool relies on ets_frontend components to compile the es2abc executable file. and you need to specify the es2abc path when using it. 63 The test cases for this tool are open source cases, and the test suite is automatically pulled during run time. 64 65