From 88a4b35e9d7bbd4bc2e2bdaba5c20d3da702d870 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Wed, 21 Aug 2024 14:59:09 +0200 Subject: [PATCH] chore: add a benchmark testing `DenseMatrix.map(...)` and `DenseMatrix.forEach(...)` (see #3251) --- test/benchmark/index.js | 1 + test/benchmark/map.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/benchmark/map.js 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()