-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a benchmark to get a feel for how fast scope variables are…
… resolved
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// test performance of resolving scope variables in the expression parser | ||
|
||
const Benchmark = require('benchmark') | ||
const math = require('../..') | ||
|
||
const scope = { a: 2, b: 3, c: 4 } | ||
const f = math.evaluate('f(x, y) = a + b + c + x + y', scope) | ||
|
||
console.log('f(5, 6) = ' + f(5, 6)) | ||
|
||
const results = [] | ||
|
||
const suite = new Benchmark.Suite() | ||
let res = 0 | ||
suite | ||
.add('evaluate f(x, y)', function () { | ||
res = f(-res, res) // just make it dynamic, using res as argument | ||
}) | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)) | ||
}) | ||
.run() |