jhugman e80995d52d
Add support for scopes with get and set methods (#2166)
* Add support for scopes with get and set methods

* Fix build for node v12

* Fixup cli and parser tests

* Add tests for simplify and evaluate

* Add example for a custom scope object

* Function calls need child scopes

* Transitionary step: Separate Safe and Scope Property calls

* Renamed identifiers in FunctionNode

* Evaluate with ObjectScopeWrapper

* Simplify tests passing

* Assume all scopes are map-like. Except parser

* Remove isMapLike check in customs.*SafeProperty() methods

* Change MapLike to Map

* Move keywords from an Object to a Set

* Move ScopeProperty functions in to scope.js

* Removed deprecation warning

* Rename scope.js to map.js

* Rename ScopeProperty to MapProperty

* Add tests and docs for map.js

* Put back the micro-optimization of function calls

* Use Map in the parser

* Called scope methods directly in cli.js

* Coercing of scope into a Map is done in Node, not evaluate

* Move createSubScope to its own file

* Fixup following self-review

* Add scope docs

* Final self-review changes

* Address reviewer comments

* Remove MapProperty witness marks

* Converted broken benchmark possibly lost in a rebase

* Use bare map as scope in benchmark

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2021-05-16 13:33:01 +02:00
..
2019-07-20 13:46:31 +02:00

Benchmarks

This directory contains benchmarks which can be used when working on performance improvements of math.js.

How to run

First build the source code once:

$ npm install
$ npm run build

To run all benchmarks:

$ node index.js

To run a single set of benchmarks:

$ node expression_parser.js

Python benchmarks

Install python, and the python library numpy, then run the benchmarks:

$ python matrix_operations_python.py

Octave benchmarks

For matrix operations, there is a small benchmark for Octave. Open Octave, run the script matrix_operations_octave.m

To do

  • use larger matrix, like 250x250 instead of 25x25
  • Compare expression parsers
    • math.js
    • expr-eval
    • jsep
    • math-expression-evaluator