Skip to content

Commit 87966e4

Browse files
committed
chore: fix randommatrix util
1 parent 255e351 commit 87966e4

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

benchmark/combinationOfCardinalityAndSize.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { run, bench, group, do_not_optimize } from 'mitata';
1+
import { run, bench, do_not_optimize, lineplot } from 'mitata';
22
import { xSequentialFillFromStep } from 'ml-spectra-processing';
33

44
import { SparseMatrix } from '../src/index.js';
@@ -13,15 +13,15 @@ camelcase: 0
1313
*/
1414
// Prepare matrices once
1515
const cardinalities = Array.from(
16-
xSequentialFillFromStep({ from: 10, step: 5, size: 25 }),
16+
xSequentialFillFromStep({ from: 10, step: 5, size: 2 }),
1717
);
1818

1919
// const dimensions = Array.from(
2020
// xSequentialFillFromStep({ from: 700, step: 100, size: 13 }),
2121
// );
2222

2323
const dimensions = [512];
24-
group('comparation internal method', () => {
24+
lineplot(() => {
2525
bench('hibrid($cardinality,$dimension)', function* (ctx) {
2626
const cardinality = ctx.get('cardinality');
2727
const size = ctx.get('dimension');
@@ -104,12 +104,12 @@ const results = await run({
104104
// warmup_samples: 10,
105105
// warmup_threshold: 100, // ms
106106
// Longer minimum time for stable measurements
107-
min_cpu_time: 2000, // 2 seconds minimum
108-
// Batch settings to reduce variance
109-
batch_samples: 5,
110-
batch_threshold: 10, // ms
111-
// Enable colors
112-
colors: true,
107+
// min_cpu_time: 2000, // 2 seconds minimum
108+
// // Batch settings to reduce variance
109+
// batch_samples: 5,
110+
// batch_threshold: 10, // ms
111+
// // Enable colors
112+
// colors: true,
113113
});
114114

115115
// Process and store results

benchmark/utils/randomMatrix.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export function randomMatrix(rows, cols, density = 0.01) {
1+
export function randomMatrix(rows, cols, cardinality) {
22
const total = rows * cols;
3-
const cardinality = Math.ceil(total * density);
43
const positions = new Set();
54

65
// Generate unique random positions

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class SparseMatrix {
165165

166166
if (this.cardinality < 42 && other.cardinality < 42) {
167167
return this._mmulSmall(other);
168-
} else if (other.rows > 100 && other.cardinality < 110) {
168+
} else if (other.rows > 100 && other.cardinality < 100) {
169169
return this._mmulLowDensity(other);
170170
}
171171

0 commit comments

Comments
 (0)