const fc1 = require('
[email protected]');
const fc2 = require('
[email protected]');
const { performance } = require('perf_hooks');
const measurePerf = async (label, measure) => {
const time1 = [];
const time2 = [];
for (let idx = 0 ; idx !== 10000 ; ++idx) {
time1.push(await measure(fc1, idx));
time2.push(await measure(fc2, idx));
}
console.log(label);
console.log(time1.sort((a,b) => a-b)[5000]);
console.log(time2.sort((a,b) => a-b)[5000]);
}
await measurePerf('synchronous property', (fc, seed) => {
const start = performance.now();
fc.assert(fc.property(fc.nat(), fc.nat(), (a, b) => true), {seed});
return performance.now() - start;
});
await measurePerf('asynchronous property', async (fc, seed) => {
const start = performance.now();
await fc.assert(fc.asyncProperty(fc.nat(), fc.nat(), async (a, b) => true), {seed});
return performance.now() - start;
});