const array_intersect = require('./lib/index.js').default; const intersectionOf = require("intersection-of").intersectionOf; const arrayIntersectionX = require("array-intersection-x").default; const intersect = require('intersect'); var Benchmark = require('benchmark'); function make_input(arrays, elems, intersect) { return new Array(arrays) .fill() .map(_ => new Array(elems) .fill() .map((_,j) => j { let input = make_input(a,b,c); let name = `${a} arrays of ${b} elements, with an intersection of size ${c}`; new Benchmark.Suite(name) .add("fast_array_intersect", () => array_intersect(input)) .add("intersect", () => intersect(input)) .add("intersection-of", () => intersectionOf.apply(null, input)) .add("array-intersection-x", () => arrayIntersectionX.apply(null, input)) .on('start', function(event) { console.log(`\n${name}...`); }) .on('cycle', function(event) { console.log(String(event.target)); }) .on('complete', function() { console.log('Fastest is ' + this.filter('fastest').map('name')); }) .run(); });