Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Benchmark = require('benchmark');
const {randomPoint, randomPolygon} = require('@turf/random');
const geojsonRbush = require('./').default;
// Fixtures
const points = randomPoint(3);
const point = points.features[0];
const polygons = randomPolygon(3);
const polygon = polygons.features[0];
// Load trees before (used to benchmark search)
const pointsTree = geojsonRbush();
pointsTree.load(points);
const polygonsTree = geojsonRbush();
polygonsTree.load(polygons);
/**
* Benchmark Results
*
* rbush.points x 313,979 ops/sec ±10.60% (67 runs sampled)
* rbush.polygons x 428,333 ops/sec ±1.69% (70 runs sampled)
* search.points x 5,986,675 ops/sec ±7.95% (77 runs sampled)
* search.polygons x 6,481,248 ops/sec ±0.93% (90 runs sampled)
*/
const Benchmark = require('benchmark');
const random = require('@turf/random');
const meta = require('./');
const fixtures = {
point: random.randomPoint(),
points: random.randomPoint(1000),
polygon: random.randomPolygon(),
polygons: random.randomPolygon(1000)
};
const suite = new Benchmark.Suite('turf-meta');
/**
* Benchmark Results
* segmentEach - point x 3,541,484 ops/sec ±6.03% (88 runs sampled)
* segmentReduce - point x 3,245,821 ops/sec ±0.95% (86 runs sampled)
* flattenEach - point x 6,447,234 ops/sec ±5.56% (79 runs sampled)
* flattenReduce - point x 5,415,555 ops/sec ±1.28% (85 runs sampled)
* coordEach - point x 19,941,547 ops/sec ±0.64% (84 runs sampled)
* coordReduce - point x 11,959,189 ops/sec ±1.53% (85 runs sampled)
* propEach - point x 29,317,809 ops/sec ±1.38% (85 runs sampled)
* propReduce - point x 14,552,839 ops/sec ±1.06% (90 runs sampled)
* geomEach - point x 22,137,140 ops/sec ±0.95% (88 runs sampled)
'use strict';
const { times } = require('@terascope/utils');
const turf = require('@turf/random');
const { Suite } = require('./helpers');
const { Parser, createJoinQuery, FieldType } = require('../dist/src');
const greenlandGeoData = require('./fixtures/greenland.json');
const featureCollection = turf.randomPolygon(1, { num_vertices: 800 });
const [polygon] = featureCollection.features;
const polyInput = { location: polygon.geometry };
const multipolyInput = { location: greenlandGeoData };
const typeConfig = { location: FieldType.GeoJSON };
const { query: polyQuery, variables: polyVariables } = createJoinQuery(polyInput, { typeConfig });
const {
query: multiPolyQuery,
variables: multiPolyVariables
} = createJoinQuery(multipolyInput, { typeConfig });
const multiPolyConfig = {
type_config: typeConfig,
variables: multiPolyVariables
const Benchmark = require('benchmark');
const random = require('@turf/random');
const meta = require('./');
const fixtures = {
point: random.randomPoint(),
points: random.randomPoint(1000),
polygon: random.randomPolygon(),
polygons: random.randomPolygon(1000)
};
const suite = new Benchmark.Suite('turf-meta');
/**
* Benchmark Results
* segmentEach - point x 3,541,484 ops/sec ±6.03% (88 runs sampled)
* segmentReduce - point x 3,245,821 ops/sec ±0.95% (86 runs sampled)
* flattenEach - point x 6,447,234 ops/sec ±5.56% (79 runs sampled)
* flattenReduce - point x 5,415,555 ops/sec ±1.28% (85 runs sampled)
* coordEach - point x 19,941,547 ops/sec ±0.64% (84 runs sampled)
* coordReduce - point x 11,959,189 ops/sec ±1.53% (85 runs sampled)
* propEach - point x 29,317,809 ops/sec ±1.38% (85 runs sampled)
* propReduce - point x 14,552,839 ops/sec ±1.06% (90 runs sampled)
* geomEach - point x 22,137,140 ops/sec ±0.95% (88 runs sampled)
* geomReduce - point x 12,416,033 ops/sec ±0.94% (88 runs sampled)