diff --git a/test/benchmark/index.js b/test/benchmark/index.js index bc1697cc3..2f33e29d9 100644 --- a/test/benchmark/index.js +++ b/test/benchmark/index.js @@ -6,3 +6,4 @@ import './matrix_operations.js' import './prime.js' import './load.js' import './scope_variables.js' +import './map.js' diff --git a/test/benchmark/map.js b/test/benchmark/map.js new file mode 100644 index 000000000..3969b37ba --- /dev/null +++ b/test/benchmark/map.js @@ -0,0 +1,18 @@ +import Benchmark from 'benchmark' +import { ones } from '../../lib/esm/index.js' + +const denseMatrix = ones(100, 100, 'dense') + +new Benchmark.Suite() + .add('DenseMatrix.map(...)', () => { + denseMatrix.map(value => value) + }) + .add('DenseMatrix.forEach(...)', () => { + denseMatrix.forEach(() => { /* noop */ }) + }) + .on('cycle', function (event) { + console.log(String(event.target)) + }) + .on('complete', function () { + }) + .run()