Skip to content

Commit

Permalink
chore: add a benchmark testing DenseMatrix.map(...) and `DenseMatri…
Browse files Browse the repository at this point in the history
…x.forEach(...)` (see #3251)
  • Loading branch information
josdejong committed Aug 21, 2024
1 parent 84effa7 commit 88a4b35
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/benchmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ import './matrix_operations.js'
import './prime.js'
import './load.js'
import './scope_variables.js'
import './map.js'
18 changes: 18 additions & 0 deletions test/benchmark/map.js
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 88a4b35

Please sign in to comment.