chore: add a benchmark testing DenseMatrix.map(...) and DenseMatrix.forEach(...) (see #3251)

This commit is contained in:
Jos de Jong 2024-08-21 14:59:09 +02:00
parent 84effa73fc
commit 88a4b35e9d
2 changed files with 19 additions and 0 deletions

View File

@ -6,3 +6,4 @@ import './matrix_operations.js'
import './prime.js'
import './load.js'
import './scope_variables.js'
import './map.js'

18
test/benchmark/map.js Normal file
View File

@ -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()