Skip to content

Commit d7acad1

Browse files
🚀 perf: Improve benchmark.
1 parent 2e523f2 commit d7acad1

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

Diff for: _benchmark/index.js

+26-9
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function add (op, ...args) {
5555
start: function start () {
5656
var suite = new benchmark.Suite();
5757

58-
console.log('Benchmarking: ' + op);
58+
console.log('Benchmarking: ' + key);
5959

6060
Object.keys(fns).forEach(function (name) {
6161
if (!filter.test(name)) return ;
@@ -121,7 +121,8 @@ if (fast) {
121121
benchmark.options.maxTime = 1;
122122
benchmark.options.minSamples = 3;
123123
} else {
124-
benchmark.options.minTime = 1;
124+
benchmark.options.minTime = 3;
125+
benchmark.options.minSamples = 10;
125126
}
126127

127128
const fns = {
@@ -353,7 +354,11 @@ function newFixture ( ) {
353354
const pow1 = fn.fromRed && fn.fromRed(am1);
354355
return {
355356
a32, b32, a64, b64, a128, b128, a256, b256, a512, b512, a768, b768,
356-
a1024, b1024, a2048, b2048, a4096, b4096, a8192, b8192,
357+
_a32, _b32, _a64, _b64, _a128, _b128, _a256, _b256, _a512, _b512, _a768, _b768,
358+
a1024, b1024, a2048, b2048,
359+
a4096, b4096, a8192, b8192,
360+
_a1024, _b1024, _a2048, _b2048,
361+
_a4096, _b4096, _a8192, _b8192,
357362
as1, am1, pow1, a10base, a16base,
358363
} ;
359364
}
@@ -373,12 +378,22 @@ while (fixtures.length < NFIXTURES) fixtures.push(newFixture()) ;
373378

374379
add('from10', 'a10base');
375380
add('from16', 'a16base');
376-
add('to10', 'a32');
377-
add('to16', 'a32');
378-
add('add', 'a32', 'b32');
379-
add('add', 'a768', 'b768');
380-
add('sub', 'a32', 'b32');
381-
add('sub', 'a768', 'b768');
381+
382+
const ALL = [
383+
'a32' ,
384+
'a64' ,
385+
'a128' ,
386+
'a256' ,
387+
'a512' ,
388+
'a768' ,
389+
'a1024' ,
390+
'a2048' ,
391+
'a4096' ,
392+
'a8192' ,
393+
] ;
394+
395+
for ( const x of ALL ) add('from16', '_'+x) ;
396+
for ( const x of ALL ) add('to16', x) ;
382397

383398
const ALL_OPS = [
384399
[ 'a32', 'b32' ] ,
@@ -393,6 +408,8 @@ const ALL_OPS = [
393408
[ 'a8192', 'b8192' ] ,
394409
] ;
395410

411+
for ( const [ a , b ] of ALL_OPS ) add('add', a, b) ;
412+
for ( const [ a , b ] of ALL_OPS ) add('sub', a, b) ;
396413
for ( const [ a , b ] of ALL_OPS ) add('mul', a, b) ;
397414
for ( const [ a , b ] of ALL_OPS ) add('div', a, b) ;
398415

0 commit comments

Comments
 (0)