Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move bench under test folder #979

Merged
merged 11 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"ignorePatterns": ["build/*.js", "*.json"],
"overrides": [
{
"files": ["debug/**", "bench/**", "test/**", "src/style-spec/**"],
"files": ["debug/**", "test/**", "src/style-spec/**"],
"rules": {
"jsdoc/check-param-names": "off",
"jsdoc/require-param": "off",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Copy benchmarks_generated.js
run: |
mkdir tmp
cp bench/versions/benchmarks_generated.js tmp
cp bench/versions/benchmarks_generated.js.map tmp
cp test/bench/versions/benchmarks_generated.js tmp
cp test/bench/versions/benchmarks_generated.js.map tmp

- name: Upload to GitHub Pages (main)
if: startsWith(github.ref, 'refs/heads/main')
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/types/
/dist/
/dist_type/
/bench/results/
/test/bench/results/
*.es.js
*.js.map
node_modules
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ See [`test/README.md`](./test/README.md).

## Writing & Running Benchmarks

See [`bench/README.md`](./bench/README.md).
See [`test/bench/README.md`](./test/bench/README.md).

## Code Conventions

Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@
"build-style-spec": "rollup --configPlugin @rollup/plugin-typescript -c rollup.config.style-spec.ts && rollup --configPlugin @rollup/plugin-typescript -c rollup.config.style-spec.ts --environment esm",
"build-diagrams": "cd docs/diagrams; ls *.plantuml | xargs -I {} puml generate --svg {} -o {}.svg",
"watch-css": "postcss --watch -o dist/maplibre-gl.css src/css/maplibre-gl.css",
"build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c bench/rollup_config_benchmarks.ts",
"watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c bench/rollup_config_benchmarks.ts --watch",
"build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts",
"watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch",
"start-server": "st --no-cache -H 0.0.0.0 --port 9966 --index index.html .",
"start-server-at-test": "st --no-cache -H 0.0.0.0 --port 9966 --index index.html -d test",
"start": "run-p watch-css start-server",
"start-debug": "run-p watch-css watch-dev start-server",
"start-bench": "run-p watch-css watch-benchmarks start-server",
"lint": "eslint --cache --ext \".ts,.js,.html\" --ignore-path .gitignore src test build debug/*.html bench jest.config.js",
"start-bench": "run-p watch-css watch-benchmarks start-server-at-test",
"lint": "eslint --cache --ext \".ts,.js,.html\" --ignore-path .gitignore src test build debug/*.html jest.config.js",
"lint-docs": "documentation lint src/index.ts",
"lint-css": "stylelint \"src/css/maplibre-gl.css\"",
"test": "run-s lint lint-css lint-docs test-unit",
Expand All @@ -168,8 +169,8 @@
"test-expression": "jest test/integration/expression",
"test-unit": "jest ./src",
"codegen": "npm run generate-style-code && npm run generate-struct-arrays && npm run generate-style-spec && npm run generate-shaders",
"benchmark": "node --loader ts-node/esm --experimental-specifier-resolution=node bench/run-benchmarks.ts",
"gl-stats": "node --loader ts-node/esm --experimental-specifier-resolution=node bench/gl-stats.ts",
"benchmark": "node --loader ts-node/esm --experimental-specifier-resolution=node test/bench/run-benchmarks.ts",
"gl-stats": "node --loader ts-node/esm --experimental-specifier-resolution=node test/bench/gl-stats.ts",
"postinstall": "npm run codegen && npm run generate-query-test-fixtures",
"prepare": "husky install"
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Benchmark from '../lib/benchmark';

import spec from '../../src/style-spec/reference/latest';
import convertFunction from '../../src/style-spec/function/convert';
import {isFunction, createFunction} from '../../src/style-spec/function';
import {createPropertyExpression} from '../../src/style-spec/expression';
import spec from '../../../src/style-spec/reference/latest';
import convertFunction from '../../../src/style-spec/function/convert';
import {isFunction, createFunction} from '../../../src/style-spec/function';
import {createPropertyExpression} from '../../../src/style-spec/expression';
import fetchStyle from '../lib/fetch_style';

import type {StyleSpecification} from '../../src/style-spec/types';
import type {StylePropertySpecification} from '../../src/style-spec/style-spec';
import type {StylePropertyExpression} from '../../src/style-spec/expression';
import type {StyleSpecification} from '../../../src/style-spec/types';
import type {StylePropertySpecification} from '../../../src/style-spec/style-spec';
import type {StylePropertyExpression} from '../../../src/style-spec/expression';

interface DataT {
propertySpec: StylePropertySpecification;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Benchmark from '../lib/benchmark';

import createFilter from '../../src/style-spec/feature_filter';
import createFilter from '../../../src/style-spec/feature_filter';
import filters from '../data/filters.json';

export default class FilterCreate extends Benchmark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Benchmark from '../lib/benchmark';
import {VectorTile} from '@mapbox/vector-tile';
import Pbf from 'pbf';
import createFilter from '../../src/style-spec/feature_filter';
import createFilter from '../../../src/style-spec/feature_filter';
import filters from '../data/filters.json';
import assert from 'assert';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Benchmark from '../lib/benchmark';
import createMap from '../lib/create_map';
import type {StyleSpecification} from '../../src/style-spec/types';
import type {StyleSpecification} from '../../../src/style-spec/types';

export default class HillshadeLoad extends Benchmark {
style: StyleSpecification;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {StyleSpecification} from '../../src/style-spec/types';
import type {StyleSpecification} from '../../../src/style-spec/types';
import Benchmark from '../lib/benchmark';
import fetchStyle from '../lib/fetch_style';
import TileParser from '../lib/tile_parser';
import {OverscaledTileID} from '../../src/source/tile_id';
import {OverscaledTileID} from '../../../src/source/tile_id';

export default class Layout extends Benchmark {
tiles: Array<{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Benchmark from '../lib/benchmark';
import createMap from '../lib/create_map';
import type Map from '../../src/ui/map';
import type Map from '../../../src/ui/map';

const width = 1024;
const height = 768;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Benchmark from '../lib/benchmark';
import createMap from '../lib/create_map';
import type Map from '../../src/ui/map';
import type Map from '../../../src/ui/map';

const width = 1024;
const height = 768;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Benchmark from '../lib/benchmark';
import createMap from '../lib/create_map';
import type Map from '../../src/ui/map';
import type {PointLike} from '../../src/ui/camera';
import type Map from '../../../src/ui/map';
import type {PointLike} from '../../../src/ui/camera';

const width = 1024;
const height = 768;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Benchmark from '../lib/benchmark';
import createMap from '../lib/create_map';
import type Map from '../../src/ui/map';
import type {LngLatLike} from '../../src/geo/lng_lat';
import type Map from '../../../src/ui/map';
import type {LngLatLike} from '../../../src/geo/lng_lat';

const width = 1024;
const height = 768;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {StyleSpecification} from '../../src/style-spec/types';
import type {StyleSpecification} from '../../../src/style-spec/types';
import Benchmark from '../lib/benchmark';
import createStyleLayer from '../../src/style/create_style_layer';
import deref from '../../src/style-spec/deref';
import createStyleLayer from '../../../src/style/create_style_layer';
import deref from '../../../src/style-spec/deref';
import fetchStyle from '../lib/fetch_style';

export default class StyleLayerCreate extends Benchmark {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {StyleSpecification} from '../../src/style-spec/types';
import type {StyleSpecification} from '../../../src/style-spec/types';
import Benchmark from '../lib/benchmark';
import validateStyle from '../../src/style-spec/validate_style.min';
import validateStyle from '../../../src/style-spec/validate_style.min';
import fetchStyle from '../lib/fetch_style';

export default class StyleValidate extends Benchmark {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Layout from './layout';
import SymbolBucket from '../../src/data/bucket/symbol_bucket';
import {performSymbolLayout} from '../../src/symbol/symbol_layout';
import {OverscaledTileID} from '../../src/source/tile_id';
import SymbolBucket from '../../../src/data/bucket/symbol_bucket';
import {performSymbolLayout} from '../../../src/symbol/symbol_layout';
import {OverscaledTileID} from '../../../src/source/tile_id';

export default class SymbolLayout extends Layout {
parsedTiles: Array<any>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {StyleSpecification} from '../../src/style-spec/types';
import type {StyleSpecification} from '../../../src/style-spec/types';
import Benchmark from '../lib/benchmark';
import fetchStyle from '../lib/fetch_style';
import TileParser from '../lib/tile_parser';
import {OverscaledTileID} from '../../src/source/tile_id';
import {serialize, deserialize} from '../../src/util/web_worker_transfer';
import {OverscaledTileID} from '../../../src/source/tile_id';
import {serialize, deserialize} from '../../../src/util/web_worker_transfer';

export default class WorkerTransfer extends Benchmark {
parser: TileParser;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bench/gl-stats.ts → test/bench/gl-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {execSync} from 'child_process';

const maplibreGLJSSrc = fs.readFileSync('dist/maplibre-gl.js', 'utf8');
const maplibreGLCSSSrc = fs.readFileSync('dist/maplibre-gl.css', 'utf8');
const benchSrc = fs.readFileSync('bench/gl-stats.html', 'utf8');
const benchSrc = fs.readFileSync('test/bench/gl-stats.html', 'utf8');

const benchHTML = benchSrc
.replace(/<script src="..\/dist\/maplibre-gl.js"><\/script>/, `<script>${maplibreGLJSSrc}</script>`);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bench/lib/create_map.ts → test/bench/lib/create_map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Map from '../../src/ui/map';
import Map from '../../../src/ui/map';

const createMap = (options: any): Promise<Map> => {
return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion bench/lib/fetch_style.ts → test/bench/lib/fetch_style.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {StyleSpecification} from '../../src/style-spec/types';
import type {StyleSpecification} from '../../../src/style-spec/types';

export default function fetchStyle(value: string | StyleSpecification): Promise<StyleSpecification> {
return typeof value === 'string' ?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MercatorCoordinate from '../../src/geo/mercator_coordinate';
import {OverscaledTileID} from '../../src/source/tile_id';
import MercatorCoordinate from '../../../src/geo/mercator_coordinate';
import {OverscaledTileID} from '../../../src/source/tile_id';

export type LocationsWithTileID = {
description: string;
Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions bench/lib/tile_parser.ts → test/bench/lib/tile_parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import Protobuf from 'pbf';
import VT from '@mapbox/vector-tile';
import assert from 'assert';

import deref from '../../src/style-spec/deref';
import Style from '../../src/style/style';
import {Evented} from '../../src/util/evented';
import {RequestManager} from '../../src/util/request_manager';
import WorkerTile from '../../src/source/worker_tile';
import StyleLayerIndex from '../../src/style/style_layer_index';

import type {StyleSpecification} from '../../src/style-spec/types';
import type {WorkerTileResult} from '../../src/source/worker_source';
import type {OverscaledTileID} from '../../src/source/tile_id';
import type {TileJSON} from '../../src/types/tilejson';
import type Map from '../../src/ui/map';
import deref from '../../../src/style-spec/deref';
import Style from '../../../src/style/style';
import {Evented} from '../../../src/util/evented';
import {RequestManager} from '../../../src/util/request_manager';
import WorkerTile from '../../../src/source/worker_tile';
import StyleLayerIndex from '../../../src/style/style_layer_index';

import type {StyleSpecification} from '../../../src/style-spec/types';
import type {WorkerTileResult} from '../../../src/source/worker_source';
import type {OverscaledTileID} from '../../../src/source/tile_id';
import type {TileJSON} from '../../../src/types/tilejson';
import type Map from '../../../src/ui/map';

class StubMap extends Evented {
style: Style;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import replace from '@rollup/plugin-replace';
import {plugins, nodeResolve} from '../build/rollup_plugins';
import {plugins, nodeResolve} from '../../build/rollup_plugins';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import {execSync} from 'child_process';
Expand Down Expand Up @@ -30,7 +30,7 @@ const allPlugins = plugins(true, true).concat(replace(replaceConfig));
const intro = fs.readFileSync('rollup/bundle_prelude.js', 'utf8');

const splitConfig = (name: string): RollupOptions[] => [{
input: [`bench/${name}/benchmarks.ts`, 'src/source/worker.ts'],
input: [`test/bench/${name}/benchmarks.ts`, 'src/source/worker.ts'],
output: {
dir: `rollup/build/benchmarks/${name}`,
format: 'amd',
Expand All @@ -42,7 +42,7 @@ const splitConfig = (name: string): RollupOptions[] => [{
}, {
input: `rollup/benchmarks_${name}.js`,
output: {
file: `bench/${name}/benchmarks_generated.js`,
file: `test/bench/${name}/benchmarks_generated.js`,
format: 'umd',
indent: false,
sourcemap: true,
Expand All @@ -53,10 +53,10 @@ const splitConfig = (name: string): RollupOptions[] => [{
}];

const viewConfig: RollupOptions = {
input: 'bench/benchmarks_view.tsx',
input: 'test/bench/benchmarks_view.tsx',
output: {
name: 'Benchmarks',
file: 'bench/benchmarks_view_generated.js',
file: 'test/bench/benchmarks_view_generated.js',
format: 'umd',
indent: false,
sourcemap: false
Expand Down
6 changes: 4 additions & 2 deletions bench/run-benchmarks.ts → test/bench/run-benchmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ const argv = minimist(process.argv.slice(2));
const formatTime = (v) => `${v.toFixed(4)} ms`;
const formatRegression = (v) => v.correlation < 0.9 ? '\u2620\uFE0F' : v.correlation < 0.99 ? '\u26A0\uFE0F' : ' ';

const dir = './bench/results';
const dir = './test/bench/results';
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
HarelM marked this conversation as resolved.
Show resolved Hide resolved

const url = new URL('http://localhost:9966/bench/versions/');
const url = new URL('http://localhost:9966/bench/versions');

for (const compare of [].concat(argv.compare).filter(Boolean))
url.searchParams.append('compare', compare);

console.log(`Starting headeless chrome at: ${url.toString()}`);

const browser = await chromium.launch({
headless: true,
args: ['--use-gl=angle', '--no-sandbox', '--disable-setuid-sandbox']
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import maplibregl from '../../src';
import maplibregl from '../../../src';
import locationsWithTileID from '../lib/locations_with_tile_id';
import styleBenchmarkLocations from '@mapbox/gazetteer/benchmark/style-benchmark-locations.json';
import StyleLayerCreate from '../benchmarks/style_layer_create';
Expand All @@ -8,7 +8,7 @@ import Paint from '../benchmarks/paint';
import QueryPoint from '../benchmarks/query_point';
import QueryBox from '../benchmarks/query_box';

import getWorkerPool from '../../src/util/global_worker_pool';
import getWorkerPool from '../../../src/util/global_worker_pool';

const locations = locationsWithTileID(styleBenchmarkLocations.features as GeoJSON.Feature<GeoJSON.Point>[]);

Expand Down
3 changes: 0 additions & 3 deletions bench/styles/index.html → test/bench/styles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<link rel='stylesheet' href='/dist/maplibre-gl.css'/>
</head>

<body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import maplibregl from '../../src';
import maplibregl from '../../../src';
import locationsWithTileID from '../lib/locations_with_tile_id';
import styleBenchmarkLocations from '@mapbox/gazetteer/benchmark/style-benchmark-locations.json';
import Layout from '../benchmarks/layout';
Expand All @@ -19,7 +19,7 @@ import {FunctionCreate, FunctionEvaluate, ExpressionCreate, ExpressionEvaluate}
import FilterCreate from '../benchmarks/filter_create';
import FilterEvaluate from '../benchmarks/filter_evaluate';

import getWorkerPool from '../../src/util/global_worker_pool';
import getWorkerPool from '../../../src/util/global_worker_pool';

const styleLocations = locationsWithTileID(styleBenchmarkLocations.features as GeoJSON.Feature<GeoJSON.Point>[]).filter(v => v.zoom < 15); // the used maptiler sources have a maxzoom of 14

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel='stylesheet' href='/dist/maplibre-gl.css'/>
<script src='https://unpkg.com/url-search-params@0.10.0/build/url-search-params.js'></script>
</head>

Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"include": [
"rollup.config.**",
"src/**/*.ts",
"bench/**/*.ts",
"bench/**/*.tsx",
"test/bench/**/*.ts",
"test/bench/**/*.tsx",
"build/**/*.ts"
],
"exclude": [
"node_modules",
"lib",
"dist",
"bench/**/*generated*",
"test/bench/**/*generated*",
"src/**/*.test.ts"
]
}