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 5 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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@
"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": "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",
"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 +168,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.
10 changes: 5 additions & 5 deletions bench/README.md → test/bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Benchmarks help us catch performance regressions and improve performance.

Start the benchmark server with `npm run start-bench`.

To run all benchmarks, open [the benchmark page, `http://localhost:9966/bench/versions`](http://localhost:9966/bench/versions).
To run all benchmarks, open [the benchmark page, `http://localhost:9966/test/bench/versions`](http://localhost:9966/bench/versions).
HarelM marked this conversation as resolved.
Show resolved Hide resolved

To run a specific benchmark, add its name to the url hash, for example [`http://localhost:9966/bench/versions#Layout`](http://localhost:9966/bench/versions#Layout).
To run a specific benchmark, add its name to the url hash, for example [`http://localhost:9966/test/bench/versions#Layout`](http://localhost:9966/bench/versions#Layout).
HarelM marked this conversation as resolved.
Show resolved Hide resolved

By default, the benchmark page will compare the local branch against `main` and the latest release. To change this, include one or more `compare` query parameters in the URL: E.g., [localhost:9966/bench/versions?compare=main](http://localhost:9966/bench/versions?compare=main) or [localhost:9966/bench/versions?compare=main#Layout](http://localhost:9966/bench/versions?compare=main#Layout) to compare only to main, or [localhost:9966/bench/versions?compare=v1.13.1](http://localhost:9966/bench/versions?compare=v1.13.1) to compare to `v1.13.1` (but not `main`). Versions available for comparison are the ones stored in the `gh-pages` branch, see [here](https://github.com/maplibre/maplibre-gl-js/tree/gh-pages/benchmarks).
By default, the benchmark page will compare the local branch against `main` and the latest release. To change this, include one or more `compare` query parameters in the URL: E.g., [localhost:9966/test/bench/versions?compare=main](http://localhost:9966/test/bench/versions?compare=main) or [localhost:9966/test/bench/versions?compare=main#Layout](http://localhost:9966/test/bench/versions?compare=main#Layout) to compare only to main, or [localhost:9966/test/bench/versions?compare=v1.13.1](http://localhost:9966/test/bench/versions?compare=v1.13.1) to compare to `v1.13.1` (but not `main`). Versions available for comparison are the ones stored in the `gh-pages` branch, see [here](https://github.com/maplibre/maplibre-gl-js/tree/gh-pages/benchmarks).

To run all benchmarks in headless chromium use `npm run benchmark`. As with the browser you can include one or more `--compare` arguments to change the default comparison, e.g. `npm run benchmark -- --compare main`. You can also run only specific benchmarks by passing their names as positional arguments, e.g. `npm run benchmark -- Layout Paint`.

Expand All @@ -23,9 +23,9 @@ MAPLIBRE_STYLES={YOUR STYLES HERE} npm run start-bench
```
Note: `MAPLIBRE_STYLES` takes a comma-separated list of up to 3 MapLibre styles provided as a style URL or file system path (e.g. `path/to/style-a.json,path/to/style-b.json`)

To run all benchmarks, open [the benchmark page, `http://localhost:9966/bench/styles`](http://localhost:9966/bench/styles).
To run all benchmarks, open [the benchmark page, `http://localhost:9966/test/bench/styles`](http://localhost:9966/test/bench/styles).

To run a specific benchmark, add its name to the url hash, for example [`http://localhost:9966/bench/styles#Layout`](http://localhost:9966/bench/styles#Layout).
To run a specific benchmark, add its name to the url hash, for example [`http://localhost:9966/test/bench/styles#Layout`](http://localhost:9966/test/bench/styles#Layout).

By default, the style benchmark page will run its benchmarks against `https://api.maptiler.com/maps/streets/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL`. `Layout` and `Paint` styles will run one instance of the test for each tile/location in an internal list of tiles. This behavior helps visualize the ways in which a style performs given various conditions present in each tile (CJK text, dense urban areas, rural areas, etc). `QueryBox` and `QueryPoint` use the internal list of tiles but otherwise run the same as their non-style benchmark equivalents. `StyleLayerCreate` and `StyleValidate` are not tile/location dependent and run the same way as their non-style benchmark equivalents. All other benchmark tests from the non-style suite are not used when benchmarking styles.

Expand Down
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 {
_requestManager: RequestManager;
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
4 changes: 2 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,12 +8,12 @@ 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/test/bench/versions');

for (const compare of [].concat(argv.compare).filter(Boolean))
url.searchParams.append('compare', compare);
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
4 changes: 2 additions & 2 deletions bench/styles/index.html → test/bench/styles/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<body>
<div id="benchmarks"></div>
<script src="/bench/styles/benchmarks_generated.js"></script>
<script src="/bench/benchmarks_view_generated.js"></script>
<script src="test/bench/styles/benchmarks_generated.js"></script>
<script src="test/bench/benchmarks_view_generated.js"></script>
<script>
window.Benchmarks.run(benchmarks);
</script>
Expand Down
Loading