Navigation Menu

Skip to content

Commit

Permalink
More benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Feb 5, 2019
1 parent a5df3cb commit 7e7c502
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions perf/benchmark.js
Expand Up @@ -4,20 +4,36 @@ const fcNew = require('../lib/fast-check');

const { runComplexFailure, runArraySuccess } = require('./tasks');

const MIN_SAMPLES = 20;
const MIN_SAMPLES = 1000;
const benchConf = { minSamples: MIN_SAMPLES };
const run = runArraySuccess;
const sampler = (fc, arb) => fc.sample(arb.noShrink());

Benchmark.invoke(
[
new Benchmark(`Reference`, () => run(fcOld), benchConf),
new Benchmark(`Test`, () => run(fcNew), benchConf),
new Benchmark(`Reference`, () => run(fcOld), benchConf),
new Benchmark(`Test`, () => run(fcNew), benchConf)
],
{
name: 'run',
queued: true,
onCycle: event => console.log(String(event.target))
}
);
const algos = [
{ name: 'run.complex', run: runComplexFailure },
{ name: 'run.array', run: runArraySuccess },
{ name: 'gen.array', run: fc => sampler(fc, fc.array(fc.constant('a'))) },
{ name: 'gen.stringOf', run: fc => sampler(fc, fc.stringOf(fc.constant('a'))) },
{ name: 'gen.string', run: fc => sampler(fc, fc.string()) },
{ name: 'gen.asciiString', run: fc => sampler(fc, fc.asciiString()) },
{ name: 'gen.string16bits', run: fc => sampler(fc, fc.string16bits()) },
{ name: 'gen.unicodeString', run: fc => sampler(fc, fc.unicodeString()) },
{ name: 'gen.fullUnicodeString', run: fc => sampler(fc, fc.fullUnicodeString()) },
{ name: 'gen.hexaString', run: fc => sampler(fc, fc.hexaString()) },
{ name: 'gen.base64String', run: fc => sampler(fc, fc.base64String()) }
];

for (const a of algos) {
Benchmark.invoke(
[
new Benchmark(`Reference..${a.name}`, () => a.run(fcOld), benchConf),
new Benchmark(`Test.......${a.name}`, () => a.run(fcNew), benchConf),
new Benchmark(`Reference..${a.name}`, () => a.run(fcOld), benchConf),
new Benchmark(`Test.......${a.name}`, () => a.run(fcNew), benchConf)
],
{
name: 'run',
queued: true,
onCycle: event => console.log(String(event.target))
}
);
}

0 comments on commit 7e7c502

Please sign in to comment.