Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add benchmark, support while/do-while, fix some errors #21

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,32 @@ TODO

TODO

# More
# Benchmark(TODO)

> The performance is not the core of jsscript. But It's still important for using.
> Using [v8-7 version](https://github.com/mozilla/arewefastyet/tree/master/benchmarks/v8-v7) benchmark test. (It's so old, only support es5. I will find more newer test cases in the future to replace it)

| | jsscript | [sablejs](https://github.com/sablejs/sablejs) | [eval5](https://github.com/bplok20010/eval5) |
| --- | --- | --- | --- |
| *Language* | TypeScript | JavaScript | TypeScript |
| *Support Version* | ES6(target) | ES5 | ES5 |
| *Version* | see `package.json` | `1.1.0` | `1.4.7` |
| `crypto` Score | - | - | - |
| `deltablue` Score | - | - | - |
| `earley-boyer` Score | - | - | - |
| `navier-stokes` Score | - | - | - |
| `raytrace` Score | - | - | - |
| `regexp` Score | - | - | - |
| `richards` Score | - | - | - |
| `splay` Score | - | - | - |
| **Total Score** | - | - | - |

## More

I want to use `jsscript` as package name.
But it too similar to the package `js-script` which published 10+ years ago.
I have to add the personal scope in the package name.

## Same package

- [engine262](https://github.com/engine262/engine262)
1 change: 1 addition & 0 deletions benchmark/cases/v8-7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_bundle.js
86 changes: 86 additions & 0 deletions benchmark/cases/v8-7/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
V8 Benchmark Suite
==================

This is the V8 benchmark suite: A collection of pure JavaScript
benchmarks that we have used to tune V8. The licenses for the
individual benchmarks are included in the JavaScript files.

In addition to the benchmarks, the suite consists of the benchmark
framework (base.js), which must be loaded before any of the individual
benchmark files, and two benchmark runners: An HTML version (run.html)
and a standalone JavaScript version (run.js).


Changes From Version 1 To Version 2
===================================

For version 2 the crypto benchmark was fixed. Previously, the
decryption stage was given plaintext as input, which resulted in an
error. Now, the decryption stage is given the output of the
encryption stage as input. The result is checked against the original
plaintext. For this to give the correct results the crypto objects
are reset for each iteration of the benchmark. In addition, the size
of the plain text has been increased a little and the use of
Math.random() and new Date() to build an RNG pool has been removed.

Other benchmarks were fixed to do elementary verification of the
results of their calculations. This is to avoid accidentally
obtaining scores that are the result of an incorrect JavaScript engine
optimization.


Changes From Version 2 To Version 3
===================================

Version 3 adds a new benchmark, RegExp. The RegExp benchmark is
generated by loading 50 of the most popular pages on the web and
logging all regexp operations performed. Each operation is given a
weight that is calculated from an estimate of the popularity of the
pages where it occurs and the number of times it is executed while
loading each page. Finally the literal letters in the data are
encoded using ROT13 in a way that does not affect how the regexps
match their input.


Changes from Version 3 to Version 4
===================================

The Splay benchmark is a newcomer in version 4. It manipulates a
splay tree by adding and removing data nodes, thus exercising the
memory management subsystem of the JavaScript engine.

Furthermore, all the unused parts of the Prototype library were
removed from the RayTrace benchmark. This does not affect the running
of the benchmark.


Changes from Version 4 to Version 5
===================================

Removed duplicate line in random seed code, and changed the name of
the Object.prototype.inherits function in the DeltaBlue benchmark to
inheritsFrom to avoid name clashes when running in Chromium with
extensions enabled.


Changes from Version 5 to Version 6
===================================

Removed dead code from the RayTrace benchmark and fixed a couple of
typos in the DeltaBlue implementation. Changed the Splay benchmark to
avoid converting the same numeric key to a string over and over again
and to avoid inserting and removing the same element repeatedly thus
increasing pressure on the memory subsystem. Changed the RegExp
benchmark to exercise the regular expression engine on different
input strings.

Furthermore, the benchmark runner was changed to run the benchmarks
for at least a few times to stabilize the reported numbers on slower
machines.


Changes from Version 6 to Version 7
===================================

Added the Navier-Stokes benchmark, a 2D differential equation solver
that stresses arithmetic computations on double arrays.
16 changes: 16 additions & 0 deletions benchmark/cases/v8-7/_build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const fs = require('fs')
const path = require('path')

const files = ['crypto', 'deltablue', 'earley-boyer', 'navier-stokes', 'raytrace', 'regexp', 'richards', 'splay']

function read(file) {
return fs.readFileSync(path.join(__dirname, file), 'utf8')
}

const content = [read('base.js')]
for (const file of files) {
content.push(read(`${file}.js`))
}
content.push(read('run.js'))

fs.writeFileSync(path.join(__dirname, '_bundle.js'), content.join('\n'))
Loading
Loading