From f98a164b0a1f3aa65f6c570fc622fffe93e17a1d Mon Sep 17 00:00:00 2001 From: David Contreras Date: Mon, 16 Dec 2024 11:01:19 -0600 Subject: [PATCH] Updated tests --- test/benchmark/forEach.js | 17 +++++++---------- test/benchmark/map.js | 15 ++++++--------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/test/benchmark/forEach.js b/test/benchmark/forEach.js index b9341854b1..534ebb0caf 100644 --- a/test/benchmark/forEach.js +++ b/test/benchmark/forEach.js @@ -6,9 +6,6 @@ const genericMatrix = map(ones(10, 10, 'dense'), _ => round(random(-5, 5), 2)) const numberMatrix = new DenseMatrix(genericMatrix, 'number') const array = genericMatrix.toArray() -// console.log('data', array) -// console.log('abs(data)', abs(array))npm run - const bench = new Bench({ time: 100, iterations: 100 }) .add('abs(genericMatrix)', () => { abs(genericMatrix) @@ -43,25 +40,25 @@ const bench = new Bench({ time: 100, iterations: 100 }) .add('numberMatrix.forEach(abs.signatures.number)', () => { numberMatrix.forEach(abs.signatures.number) }) - .add(pad('genericMatrix.forEach(abs+idx)'), () => { + .add('genericMatrix.forEach(abs+idx)', () => { genericMatrix.forEach((x, idx) => abs(x) + idx[0] - idx[1]) }) - .add(pad('numberMatrix.forEach(abs+idx)'), () => { + .add('numberMatrix.forEach(abs+idx)', () => { numberMatrix.forEach((x, idx) => abs(x) + idx[0] - idx[1]) }) - .add(pad('forEach(genericMatrix, abs+idx)'), () => { + .add('forEach(genericMatrix, abs+idx)', () => { forEach(genericMatrix, (x, idx) => abs(x) + idx[0] - idx[1]) }) - .add(pad('genericMatrix.forEach(abs+idx+arr)'), () => { + .add('genericMatrix.forEach(abs+idx+arr)', () => { genericMatrix.forEach((x, idx, X) => abs(x) + idx[0] - idx[1] + X.get([0, 0])) }) - .add(pad('numberMatrix.forEach(abs+idx+arr)'), () => { + .add('numberMatrix.forEach(abs+idx+arr)', () => { numberMatrix.forEach((x, idx, X) => abs(x) + idx[0] - idx[1] + X.get([0, 0])) }) - .add(pad('forEach(genericMatrix, abs+idx+arr)'), () => { + .add('forEach(genericMatrix, abs+idx+arr)', () => { forEach(genericMatrix, (x, idx, X) => abs(x) + idx[0] - idx[1] + X.get([0, 0])) }) - .add(pad('forEach(array, abs+idx+arr)'), () => { + .add('forEach(array, abs+idx+arr)', () => { forEach(array, (x, idx, X) => abs(x) + idx[0] - idx[1] + X[0][0]) }) .add() diff --git a/test/benchmark/map.js b/test/benchmark/map.js index 338a46e682..8c4b68b61e 100644 --- a/test/benchmark/map.js +++ b/test/benchmark/map.js @@ -6,9 +6,6 @@ const genericMatrix = map(ones(10, 10, 'dense'), _ => round(random(-5, 5), 2)) const numberMatrix = new DenseMatrix(genericMatrix, 'number') const array = genericMatrix.toArray() -// console.log('data', array) -// console.log('abs(data)', abs(array))npm run - const bench = new Bench({ time: 100, iterations: 100 }) .add('abs(genericMatrix)', () => { abs(genericMatrix) @@ -43,22 +40,22 @@ const bench = new Bench({ time: 100, iterations: 100 }) .add('numberMatrix.map(abs.signatures.number)', () => { numberMatrix.map(abs.signatures.number) }) - .add(pad('map(array, abs + idx)'), () => { + .add('map(array, abs + idx)', () => { map(array, (x, idx) => abs(x) + idx[0] - idx[1]) }) - .add(pad('genericMatrix.map(abs + idx)'), () => { + .add('genericMatrix.map(abs + idx)', () => { genericMatrix.map((x, idx) => abs(x) + idx[0] - idx[1]) }) - .add(pad('numberMatrix.map(abs + idx)'), () => { + .add('numberMatrix.map(abs + idx)', () => { numberMatrix.map((x, idx) => abs(x) + idx[0] - idx[1]) }) - .add(pad('map(array, abs + idx + arr)'), () => { + .add('map(array, abs + idx + arr)', () => { map(array, (x, idx, X) => abs(x) + idx[0] - idx[1] + X[0][0]) }) - .add(pad('genericMatrix.map(abs + idx + matrix)'), () => { + .add('genericMatrix.map(abs + idx + matrix)', () => { genericMatrix.map((x, idx, X) => abs(x) + idx[0] - idx[1] + X.get([0, 0])) }) - .add(pad('numberMatrix.map(abs + idx + matrix)'), () => { + .add('numberMatrix.map(abs + idx + matrix)', () => { numberMatrix.map((x, idx, X) => abs(x) + idx[0] - idx[1] + X.get([0, 0])) }) .on('cycle', function (event) {