2024-04-25 14:56:13 +03:00
|
|
|
import { bench, describe } from 'vitest';
|
|
|
|
import { intersection as intersectionToolkit } from 'es-toolkit';
|
|
|
|
import { intersection as intersectionLodash } from 'lodash';
|
|
|
|
|
2024-06-15 09:42:48 +03:00
|
|
|
describe('intersection, small arrays', () => {
|
|
|
|
const array1 = [1, 2, 3];
|
|
|
|
const array2 = [2, 4];
|
|
|
|
|
2024-06-18 04:40:07 +03:00
|
|
|
bench('es-toolkit/intersection', () => {
|
2024-06-15 09:42:48 +03:00
|
|
|
intersectionToolkit(array1, array2);
|
|
|
|
});
|
|
|
|
|
2024-06-18 04:40:07 +03:00
|
|
|
bench('lodash/intersection', () => {
|
2024-06-15 09:42:48 +03:00
|
|
|
intersectionLodash(array1, array2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('intersection, large arrays', () => {
|
|
|
|
const array1 = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 1000));
|
|
|
|
const array2 = Array.from({ length: 10000 }, () => Math.floor(Math.random() * 1000));
|
|
|
|
|
2024-06-18 04:40:07 +03:00
|
|
|
bench('es-toolkit/intersection', () => {
|
2024-06-15 09:42:48 +03:00
|
|
|
intersectionToolkit(array1, array2);
|
2024-06-04 11:19:26 +03:00
|
|
|
});
|
2024-04-25 14:56:13 +03:00
|
|
|
|
2024-06-18 04:40:07 +03:00
|
|
|
bench('lodash/intersection', () => {
|
2024-06-15 09:42:48 +03:00
|
|
|
intersectionLodash(array1, array2);
|
2024-06-04 11:19:26 +03:00
|
|
|
});
|
|
|
|
});
|