From 5973cffe9f482787e03a01a0289296e696c5ae08 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 09:07:18 +0200 Subject: [PATCH 01/16] pin react-dom to 16.3.2 to fix benchmarks build --- package.json | 2 +- yarn.lock | 120 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 73 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index a272f6357b7..4f49bf5a84c 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "puppeteer": "^1.13.0", "raw-loader": "^1.0.0", "react": "^16.7.0", - "react-dom": "^16.7.0", + "react-dom": "16.3.2", "react-helmet": "^5.2.0", "remark": "^10.0.1", "remark-html": "^9.0.0", diff --git a/yarn.lock b/yarn.lock index e6ec0cab10f..dff3f5e27de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,6 +1350,11 @@ version "9.4.6" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.6.tgz#d8176d864ee48753d053783e4e463aec86b8d82e" +"@types/node@^11.9.5": + version "11.10.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-11.10.5.tgz#fbaca34086bdc118011e1f05c47688d432f2d571" + integrity sha512-DuIRlQbX4K+d5I+GMnv+UfnGh+ist0RdlvOp+JZ7ePJ6KQONCFQv/gKYSU1ZzbVdFSUCKZOltjmpFAGGv5MdYA== + "@types/q@^1.5.1": version "1.5.1" resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.1.tgz#48fd98c1561fe718b61733daed46ff115b496e18" @@ -1457,10 +1462,10 @@ acorn@^6.0.1, acorn@^6.0.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.4.tgz#77377e7353b72ec5104550aa2d2097a2fd40b754" integrity sha512-VY4i5EKSKkofY2I+6QLTbTTN/UvEQPCo6eiwzzSaSWfpaDhOmStMCMod6wmuPciNq+XS0faCglFu2lHZpdHUtg== -acorn@^6.0.5: - version "6.0.5" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.5.tgz#81730c0815f3f3b34d8efa95cb7430965f4d887a" - integrity sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg== +acorn@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f" + integrity sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA== address@^1.0.3: version "1.0.3" @@ -5632,6 +5637,11 @@ estree-walker@^0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.5.2.tgz#d3850be7529c9580d815600b53126515e146dd39" +estree-walker@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.0.tgz#5d865327c44a618dde5699f763891ae31f257dae" + integrity sha512-peq1RfVAVzr3PU/jL31RaOjUKLoZJpObQWJJ+LgfcxDUifyLZ1RjPQZTl0pzj2uJ45b7A7XpyppXvxdEqzo4rw== + esutils@^2.0.0, esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -8142,10 +8152,10 @@ isurl@^1.0.0-alpha5: has-to-string-tag-x "^1.2.0" is-object "^1.0.1" -jest-worker@^24.0.0-alpha.9: - version "24.0.0-alpha.13" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.0.0-alpha.13.tgz#388d2136af6bdda63e27d5f0f5a09c671cccda3e" - integrity sha512-euVesuF7gpHuwsKPnUdVeB8yHcfgPKK/UF45WuvBjuJS5YD0sT+y1ngdubKrPeGGkxbWgSuU80jPtSnoHlO0fQ== +jest-worker@^24.0.0: + version "24.0.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.0.0.tgz#3d3483b077bf04f412f47654a27bba7e947f8b6d" + integrity sha512-s64/OThpfQvoCeHG963MiEZOAAxu8kHsaL/rCMF7lpdzo7vgF0CtPml9hfguOMgykgH/eOm4jFP4ibfHLruytg== dependencies: merge-stream "^1.0.1" supports-color "^6.1.0" @@ -8407,11 +8417,6 @@ latest-version@^3.0.0: dependencies: package-json "^4.0.0" -lave@^1.1.10: - version "1.1.10" - resolved "https://registry.yarnpkg.com/lave/-/lave-1.1.10.tgz#062207652c5502d7c6ff096c9de3995401f634d5" - integrity sha1-BiIHZSxVAtfG/wlsneOZVAH2NNU= - lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" @@ -8880,6 +8885,13 @@ magic-string@^0.25.1: dependencies: sourcemap-codec "^1.4.1" +magic-string@^0.25.2: + version "0.25.2" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.2.tgz#139c3a729515ec55e96e69e82a11fe890a293ad9" + integrity sha512-iLs9mPjh9IuTtRsqqhNGYcZXGei0Nh/A4xirrsqW7c+QhKVFL2vm7U09ru6cHRD22azaP/wMDgI+HCqbETMTtg== + dependencies: + sourcemap-codec "^1.4.4" + make-dir@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.2.0.tgz#6d6a49eead4aae296c53bbf3a1a008bd6c89469b" @@ -11196,14 +11208,15 @@ react-displace@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/react-displace/-/react-displace-2.3.0.tgz#6915f8f2f279a29a7b58442405c26edc3d441429" -react-dom@^16.7.0: - version "16.7.0" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.7.0.tgz#a17b2a7ca89ee7390bc1ed5eb81783c7461748b8" +react-dom@16.3.2: + version "16.3.2" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.3.2.tgz#cb90f107e09536d683d84ed5d4888e9640e0e4df" + integrity sha512-MMPko3zYncNrz/7gG17wJWUREZDvskZHXOwbttzl0F0L3wDmToyuETuo/r8Y5yvDejwYcRyWI1lvVBjLJWFwKA== dependencies: + fbjs "^0.8.16" loose-envify "^1.1.0" object-assign "^4.1.1" - prop-types "^15.6.2" - scheduler "^0.12.0" + prop-types "^15.6.0" react-helmet@^5.2.0: version "5.2.0" @@ -11933,19 +11946,19 @@ resolve@^1.1.3, resolve@^1.1.4, resolve@^1.4.0, resolve@^1.5.0: dependencies: path-parse "^1.0.5" -resolve@^1.3.2, resolve@^1.6.0: - version "1.8.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" - dependencies: - path-parse "^1.0.5" - -resolve@^1.8.1: +resolve@^1.10.0, resolve@^1.8.1: version "1.10.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.10.0.tgz#3bdaaeaf45cc07f375656dfd2e54ed0810b101ba" integrity sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg== dependencies: path-parse "^1.0.6" +resolve@^1.3.2, resolve@^1.6.0: + version "1.8.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" + dependencies: + path-parse "^1.0.5" + resp-modifier@6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/resp-modifier/-/resp-modifier-6.0.2.tgz#b124de5c4fbafcba541f48ffa73970f4aa456b4f" @@ -12005,13 +12018,13 @@ rollup-plugin-buble@^0.19.6: rollup-pluginutils "^2.3.3" rollup-plugin-commonjs@^9.2.0: - version "9.2.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.0.tgz#4604e25069e0c78a09e08faa95dc32dec27f7c89" - integrity sha512-0RM5U4Vd6iHjL6rLvr3lKBwnPsaVml+qxOGaaNUWN1lSq6S33KhITOfHmvxV3z2vy9Mk4t0g4rNlVaJJsNQPWA== + version "9.2.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.1.tgz#bb151ca8fa23600c7a03e25f9f0a45b1ee922dac" + integrity sha512-X0A/Cp/t+zbONFinBhiTZrfuUaVwRIp4xsbKq/2ohA2CDULa/7ONSJTelqxon+Vds2R2t2qJTqJQucKUC8GKkw== dependencies: estree-walker "^0.5.2" magic-string "^0.25.1" - resolve "^1.8.1" + resolve "^1.10.0" rollup-pluginutils "^2.3.3" rollup-plugin-json@^3.1.0: @@ -12031,13 +12044,12 @@ rollup-plugin-node-resolve@4.0.0: resolve "^1.8.1" rollup-plugin-replace@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.1.0.tgz#f9c07a4a89a2f8be912ee54b3f0f68d91e9ed0ae" - integrity sha512-SxrAIgpH/B5/W4SeULgreOemxcpEgKs2gcD42zXw50bhqGWmcnlXneVInQpAqzA/cIly4bJrOpeelmB9p4YXSQ== + version "2.1.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.1.1.tgz#e49cb8d07d6f91a7bf28b90b66692f2c8c0b9bba" + integrity sha512-IS5ZYBb3px0UfbDCYzKaKxelLd5dbPHhfplEXbymfvGlz9Ok44At4AjTOWe2qEax73bE8+pnMZN9C7PcVpFNlw== dependencies: - magic-string "^0.25.1" - minimatch "^3.0.2" - rollup-pluginutils "^2.0.1" + magic-string "^0.25.2" + rollup-pluginutils "^2.4.1" rollup-plugin-sourcemaps@^0.4.2: version "0.4.2" @@ -12047,14 +12059,13 @@ rollup-plugin-sourcemaps@^0.4.2: source-map-resolve "^0.5.0" rollup-plugin-terser@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-4.0.2.tgz#78936d182ae7c4ecb313403ff5d5faad1b69e2aa" - integrity sha512-M2vY7NPMa3N77/avJSJyBva4nyBTiUM0kgMoWwEAeo2Edl3MW/GoM0069FzVrfMYP3xDqcVrDbaIOqVaBD8lHQ== + version "4.0.4" + resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-4.0.4.tgz#6f661ef284fa7c27963d242601691dc3d23f994e" + integrity sha512-wPANT5XKVJJ8RDUN0+wIr7UPd0lIXBo4UdJ59VmlPCtlFsE20AM+14pe+tk7YunCsWEiuzkDBY3QIkSCjtrPXg== dependencies: "@babel/code-frame" "^7.0.0" - escodegen "^1.11.0" - jest-worker "^24.0.0-alpha.9" - lave "^1.1.10" + jest-worker "^24.0.0" + serialize-javascript "^1.6.1" terser "^3.14.1" rollup-plugin-unassert@^0.2.0: @@ -12075,7 +12086,15 @@ rollup-pluginutils@^2.0.1: estree-walker "^0.3.0" micromatch "^2.3.11" -rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.3.3: +rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.4.1: + version "2.5.0" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.5.0.tgz#23be0f05ac3972ea7b08fc7870cb91fde5b23a09" + integrity sha512-9Muh1H+XB5f5ONmKMayUoTYR1EZwHbwJJ9oZLrKT5yuTf/RLIQ5mYIGsrERquVucJmjmaAW0Y7+6Qo1Ep+5w3Q== + dependencies: + estree-walker "^0.6.0" + micromatch "^3.1.10" + +rollup-pluginutils@^2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794" integrity sha512-2XZwja7b6P5q4RZ5FhyX1+f46xi1Z3qBKigLRZ6VTZjwbN0K1IFGMlwm06Uu0Emcre2Z63l77nq/pzn+KxIEoA== @@ -12084,13 +12103,13 @@ rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.3.3: micromatch "^2.3.11" rollup@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.1.2.tgz#8d094b85683b810d0c05a16bd7618cf70d48eba7" - integrity sha512-OkdMxqMl8pWoQc5D8y1cIinYQPPLV8ZkfLgCzL6SytXeNA2P7UHynEQXI9tYxuAjAMsSyvRaWnyJDLHMxq0XAg== + version "1.7.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.7.0.tgz#2f5063c0f344f2225d1077655dc54d105a512bb2" + integrity sha512-hjuWSCgoQsFSTsmsNP4AH1l1kfkFqW82gW00V9nL81Zr3JtnKn3rvxh18jUAAEMb7qNoHj21PR5SqbK2mhBgMg== dependencies: "@types/estree" "0.0.39" - "@types/node" "*" - acorn "^6.0.5" + "@types/node" "^11.9.5" + acorn "^6.1.1" run-async@^2.2.0: version "2.3.0" @@ -12263,6 +12282,11 @@ serialize-javascript@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.4.0.tgz#7c958514db6ac2443a8abc062dc9f7886a7f6005" +serialize-javascript@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.6.1.tgz#4d1f697ec49429a847ca6f442a2a755126c4d879" + integrity sha512-A5MOagrPFga4YaKQSWHryl7AXvbQkEqpw4NNYMTNYUNV51bA8ABHgYFpqKx+YFFrw59xMV1qGH1R4AgoNIVgCw== + serve-index@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" @@ -12677,7 +12701,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" -sourcemap-codec@^1.4.1: +sourcemap-codec@^1.4.1, sourcemap-codec@^1.4.4: version "1.4.4" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.4.tgz#c63ea927c029dd6bd9a2b7fa03b3fec02ad56e9f" integrity sha512-CYAPYdBu34781kLHkaW3m6b/uUSyMOC2R61gcYMWooeuaGtjof86ZA/8T+qVPPt7np1085CR9hmMGrySwEc8Xg== From 6405641f2592025f9161c840fd80188ca6b4a5b8 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 09:29:33 +0200 Subject: [PATCH 02/16] fix benchmarks builds accidentally switching to dev mode --- bench/styles/rollup_config_benchmarks.js | 6 +++--- bench/versions/rollup_config_benchmarks.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bench/styles/rollup_config_benchmarks.js b/bench/styles/rollup_config_benchmarks.js index 93dbd8f2b04..6a895a0a9ba 100644 --- a/bench/styles/rollup_config_benchmarks.js +++ b/bench/styles/rollup_config_benchmarks.js @@ -26,21 +26,21 @@ const config = [{ output: { dir: 'rollup/build/benchmarks/styles', format: 'amd', + indent: false, sourcemap: 'inline', chunkFileNames: 'chunk1.js' }, - experimentalCodeSplitting: true, - plugins: plugins() + plugins: plugins(true, true) }, { input: 'rollup/style_benchmarks.js', output: { file: 'bench/styles/benchmarks_generated.js', format: 'umd', + indent: false, sourcemap: 'inline', intro: fs.readFileSync(require.resolve('../../rollup/bundle_prelude.js'), 'utf8') }, treeshake: false, - indent: false, plugins: [sourcemaps()], }]; diff --git a/bench/versions/rollup_config_benchmarks.js b/bench/versions/rollup_config_benchmarks.js index 87a5f00de3d..688166131c0 100644 --- a/bench/versions/rollup_config_benchmarks.js +++ b/bench/versions/rollup_config_benchmarks.js @@ -17,21 +17,21 @@ const config = [{ output: { dir: 'rollup/build/benchmarks/versions', format: 'amd', + indent: false, sourcemap: 'inline', chunkFileNames: 'chunk1.js' }, - experimentalCodeSplitting: true, - plugins: plugins() + plugins: plugins(true, true) }, { input: 'rollup/benchmarks.js', output: { file: 'bench/versions/benchmarks_generated.js', format: 'umd', + indent: false, sourcemap: 'inline', intro: fs.readFileSync(require.resolve('../../rollup/bundle_prelude.js'), 'utf8') }, treeshake: false, - indent: false, plugins: [sourcemaps()], }]; From 379a1e583df42870acb06586a45f3b0c29393040 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 09:30:00 +0200 Subject: [PATCH 03/16] remove broken share button from benchmarks --- bench/benchmarks_view.js | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/bench/benchmarks_view.js b/bench/benchmarks_view.js index f3cc6cc62d6..8b9bfa85573 100644 --- a/bench/benchmarks_view.js +++ b/bench/benchmarks_view.js @@ -377,19 +377,12 @@ class BenchmarkRow extends React.Component { } class BenchmarksTable extends React.Component { - constructor(props) { - super(props); - this.state = {sharing: false}; - this.share = this.share.bind(this); - } - render() { return (
- {this.state.sharing && }

Mapbox GL JS Benchmarks – { this.props.finished ? - Finished : + Finished : Running}

{this.props.benchmarks.map((benchmark, i) => { return ; @@ -397,26 +390,6 @@ class BenchmarksTable extends React.Component {
); } - - share() { - document.querySelectorAll('script').forEach(e => e.remove()); - const share = document.querySelector('.share'); - share.style.display = 'none'; - - const body = JSON.stringify({ - "public": true, - "files": { - "index.html": { - "content": document.body.parentElement.outerHTML - } - } - }); - this.setState({sharing: true}); - - fetch('https://api.github.com/gists', { method: 'POST', body }) - .then(response => response.json()) - .then(json => { window.location = `https://bl.ocks.org/anonymous/raw/${json.id}/`; }); - } } export default function updateUI(benchmarks, finished) { From feb48773e5399840827fda053b32cdb270d976eb Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 10:14:53 +0200 Subject: [PATCH 04/16] make benchmarks production-built for real this time; make source maps external --- .circleci/config.yml | 5 ++++- .gitignore | 4 ++-- bench/styles/rollup_config_benchmarks.js | 8 ++++---- bench/versions/rollup_config_benchmarks.js | 8 ++++---- build/rollup_plugins.js | 2 +- rollup/benchmarks.js | 2 +- rollup/style_benchmarks.js | 2 +- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ab5f96bf396..8d4fa648104 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -200,8 +200,11 @@ jobs: name: Build command: BENCHMARK_VERSION="${CIRCLE_TAG:-$CIRCLE_BRANCH} $(git rev-parse --short=7 HEAD)" yarn run build-benchmarks - run: - name: Upload + name: Upload benchmark command: aws s3 cp --acl public-read --content-type application/javascript bench/versions/benchmarks_generated.js s3://mapbox-gl-js/${CIRCLE_TAG:-$CIRCLE_BRANCH}/benchmarks.js + - run: + name: Upload source maps + command: aws s3 cp --acl public-read --content-type application/javascript bench/versions/benchmarks_generated.js.map s3://mapbox-gl-js/${CIRCLE_TAG:-$CIRCLE_BRANCH}/benchmarks.js.map deploy-release: <<: *defaults diff --git a/.gitignore b/.gitignore index 4256959b023..33732819097 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,9 @@ flow-coverage .DS_Store .nyc_output bench/versions/benchmarks_generated.js -bench/versions/benchmarks_view_generated.js +bench/versions/benchmarks_generated.js.map bench/styles/benchmarks_generated.js -bench/styles/benchmarks_view_generated.js +bench/styles/benchmarks_generated.js.map debug/access_token_generated.js debug/style_property_editor_generated.js test/integration/**/index*.html diff --git a/bench/styles/rollup_config_benchmarks.js b/bench/styles/rollup_config_benchmarks.js index 6a895a0a9ba..cac3ab1865e 100644 --- a/bench/styles/rollup_config_benchmarks.js +++ b/bench/styles/rollup_config_benchmarks.js @@ -11,7 +11,7 @@ if (process.env.MAPBOX_STYLES) { .map(style => style.match(/\.json$/) ? require(style) : style); } -const plugins = () => basePlugins().concat( +const plugins = () => basePlugins(true, true).concat( replace({ 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), @@ -28,16 +28,16 @@ const config = [{ format: 'amd', indent: false, sourcemap: 'inline', - chunkFileNames: 'chunk1.js' + chunkFileNames: 'shared.js' }, - plugins: plugins(true, true) + plugins: plugins() }, { input: 'rollup/style_benchmarks.js', output: { file: 'bench/styles/benchmarks_generated.js', format: 'umd', indent: false, - sourcemap: 'inline', + sourcemap: true, intro: fs.readFileSync(require.resolve('../../rollup/bundle_prelude.js'), 'utf8') }, treeshake: false, diff --git a/bench/versions/rollup_config_benchmarks.js b/bench/versions/rollup_config_benchmarks.js index 688166131c0..d91428664cf 100644 --- a/bench/versions/rollup_config_benchmarks.js +++ b/bench/versions/rollup_config_benchmarks.js @@ -3,7 +3,7 @@ import sourcemaps from 'rollup-plugin-sourcemaps'; import replace from 'rollup-plugin-replace'; import {plugins as basePlugins} from '../../build/rollup_plugins'; -const plugins = () => basePlugins().concat( +const plugins = () => basePlugins(true, true).concat( replace({ 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), @@ -19,16 +19,16 @@ const config = [{ format: 'amd', indent: false, sourcemap: 'inline', - chunkFileNames: 'chunk1.js' + chunkFileNames: 'shared.js' }, - plugins: plugins(true, true) + plugins: plugins() }, { input: 'rollup/benchmarks.js', output: { file: 'bench/versions/benchmarks_generated.js', format: 'umd', indent: false, - sourcemap: 'inline', + sourcemap: true, intro: fs.readFileSync(require.resolve('../../rollup/bundle_prelude.js'), 'utf8') }, treeshake: false, diff --git a/build/rollup_plugins.js b/build/rollup_plugins.js index 575f61055d6..eddfc4ee5f3 100644 --- a/build/rollup_plugins.js +++ b/build/rollup_plugins.js @@ -17,9 +17,9 @@ export const plugins = (minified, production) => [ minifyStyleSpec(), json(), glsl('./src/shaders/*.glsl', production), - production ? unassert() : false, minified ? terser() : false, buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}), + production ? unassert() : false, resolve({ browser: true, preferBuiltins: false diff --git a/rollup/benchmarks.js b/rollup/benchmarks.js index 44eef330f90..5e7e4861d48 100644 --- a/rollup/benchmarks.js +++ b/rollup/benchmarks.js @@ -1,3 +1,3 @@ -import './build/benchmarks/versions/chunk1'; +import './build/benchmarks/versions/shared'; import './build/benchmarks/versions/worker'; import './build/benchmarks/versions/benchmarks'; diff --git a/rollup/style_benchmarks.js b/rollup/style_benchmarks.js index b597fa66969..e845e179c23 100644 --- a/rollup/style_benchmarks.js +++ b/rollup/style_benchmarks.js @@ -1,3 +1,3 @@ -import './build/benchmarks/styles/chunk1'; +import './build/benchmarks/styles/shared'; import './build/benchmarks/styles/worker'; import './build/benchmarks/styles/benchmarks'; From 18d666274245a851ea47a0e074eb902945c1e1e2 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 10:25:57 +0200 Subject: [PATCH 05/16] update gl and rollup w/ plugins to hopefully fix build --- package.json | 14 +++++++------- yarn.lock | 51 ++++++++++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 4f49bf5a84c..7ce4ec5d9f1 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "eslint-plugin-react": "^7.11.1", "flow-bin": "^0.95.1", "github-slugger": "1.2.1", - "gl": "^4.1.1", + "gl": "^4.2.2", "glob": "^7.0.3", "is-builtin-module": "^3.0.0", "jsdom": "^13.0.0", @@ -89,14 +89,14 @@ "remark-html": "^9.0.0", "remark-react": "^5.0.1", "request": "^2.79.0", - "rollup": "^1.1.2", + "rollup": "^1.7.0", "rollup-plugin-buble": "^0.19.6", - "rollup-plugin-commonjs": "^9.2.0", - "rollup-plugin-json": "^3.1.0", - "rollup-plugin-node-resolve": "4.0.0", - "rollup-plugin-replace": "^2.1.0", + "rollup-plugin-commonjs": "^9.2.1", + "rollup-plugin-json": "^4.0.0", + "rollup-plugin-node-resolve": "^4.0.1", + "rollup-plugin-replace": "^2.1.1", "rollup-plugin-sourcemaps": "^0.4.2", - "rollup-plugin-terser": "^4.0.2", + "rollup-plugin-terser": "^4.0.4", "rollup-plugin-unassert": "^0.2.0", "sinon": "^7.1.1", "slugg": "^1.2.1", diff --git a/yarn.lock b/yarn.lock index dff3f5e27de..9b3a830b903 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6513,9 +6513,10 @@ gl-matrix@^3.0.0: resolved "https://registry.yarnpkg.com/gl-matrix/-/gl-matrix-3.0.0.tgz#888301ac7650e148c3865370e13ec66d08a8381f" integrity sha512-PD4mVH/C/Zs64kOozeFnKY8ybhgwxXXQYGWdB4h68krAHknWJgk9uKOn6z8YElh5//vs++90pb6csrTIDWnexA== -gl@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/gl/-/gl-4.1.1.tgz#999383a9ec2863c6d9db9c61866ddb96b4be1998" +gl@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/gl/-/gl-4.2.2.tgz#e5aa1a7a9ccb5f36464763ff9454f41f2fa59424" + integrity sha512-RiFX+eUrMiVXyYaO1/tsHE8ex+a/52GY2mTE5MjUWE6gJvRFqGYwE6psPtEeiucBlX7DDmHe2QjJ4qyT/ubrYA== dependencies: bindings "^1.2.1" bit-twiddle "^1.0.2" @@ -12017,7 +12018,7 @@ rollup-plugin-buble@^0.19.6: buble "^0.19.6" rollup-pluginutils "^2.3.3" -rollup-plugin-commonjs@^9.2.0: +rollup-plugin-commonjs@^9.2.1: version "9.2.1" resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.2.1.tgz#bb151ca8fa23600c7a03e25f9f0a45b1ee922dac" integrity sha512-X0A/Cp/t+zbONFinBhiTZrfuUaVwRIp4xsbKq/2ohA2CDULa/7ONSJTelqxon+Vds2R2t2qJTqJQucKUC8GKkw== @@ -12027,23 +12028,23 @@ rollup-plugin-commonjs@^9.2.0: resolve "^1.10.0" rollup-pluginutils "^2.3.3" -rollup-plugin-json@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-3.1.0.tgz#7c1daf60c46bc21021ea016bd00863561a03321b" - integrity sha512-BlYk5VspvGpjz7lAwArVzBXR60JK+4EKtPkCHouAWg39obk9S61hZYJDBfMK+oitPdoe11i69TlxKlMQNFC/Uw== +rollup-plugin-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-json/-/rollup-plugin-json-4.0.0.tgz#a18da0a4b30bf5ca1ee76ddb1422afbb84ae2b9e" + integrity sha512-hgb8N7Cgfw5SZAkb3jf0QXii6QX/FOkiIq2M7BAQIEydjHvTyxXHQiIzZaTFgx1GK0cRCHOCBHIyEkkLdWKxow== dependencies: - rollup-pluginutils "^2.3.1" + rollup-pluginutils "^2.5.0" -rollup-plugin-node-resolve@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.0.0.tgz#9bc6b8205e9936cc0e26bba2415f1ecf1e64d9b2" - integrity sha512-7Ni+/M5RPSUBfUaP9alwYQiIKnKeXCOHiqBpKUl9kwp3jX5ZJtgXAait1cne6pGEVUUztPD6skIKH9Kq9sNtfw== +rollup-plugin-node-resolve@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.0.1.tgz#f95765d174e5daeef9ea6268566141f53aa9d422" + integrity sha512-fSS7YDuCe0gYqKsr5OvxMloeZYUSgN43Ypi1WeRZzQcWtHgFayV5tUSPYpxuaioIIWaBXl6NrVk0T2/sKwueLg== dependencies: builtin-modules "^3.0.0" is-module "^1.0.0" - resolve "^1.8.1" + resolve "^1.10.0" -rollup-plugin-replace@^2.1.0: +rollup-plugin-replace@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.1.1.tgz#e49cb8d07d6f91a7bf28b90b66692f2c8c0b9bba" integrity sha512-IS5ZYBb3px0UfbDCYzKaKxelLd5dbPHhfplEXbymfvGlz9Ok44At4AjTOWe2qEax73bE8+pnMZN9C7PcVpFNlw== @@ -12058,7 +12059,7 @@ rollup-plugin-sourcemaps@^0.4.2: rollup-pluginutils "^2.0.1" source-map-resolve "^0.5.0" -rollup-plugin-terser@^4.0.2: +rollup-plugin-terser@^4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-4.0.4.tgz#6f661ef284fa7c27963d242601691dc3d23f994e" integrity sha512-wPANT5XKVJJ8RDUN0+wIr7UPd0lIXBo4UdJ59VmlPCtlFsE20AM+14pe+tk7YunCsWEiuzkDBY3QIkSCjtrPXg== @@ -12086,14 +12087,6 @@ rollup-pluginutils@^2.0.1: estree-walker "^0.3.0" micromatch "^2.3.11" -rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.4.1: - version "2.5.0" - resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.5.0.tgz#23be0f05ac3972ea7b08fc7870cb91fde5b23a09" - integrity sha512-9Muh1H+XB5f5ONmKMayUoTYR1EZwHbwJJ9oZLrKT5yuTf/RLIQ5mYIGsrERquVucJmjmaAW0Y7+6Qo1Ep+5w3Q== - dependencies: - estree-walker "^0.6.0" - micromatch "^3.1.10" - rollup-pluginutils@^2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.3.3.tgz#3aad9b1eb3e7fe8262820818840bf091e5ae6794" @@ -12102,7 +12095,15 @@ rollup-pluginutils@^2.3.3: estree-walker "^0.5.2" micromatch "^2.3.11" -rollup@^1.1.2: +rollup-pluginutils@^2.4.1, rollup-pluginutils@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.5.0.tgz#23be0f05ac3972ea7b08fc7870cb91fde5b23a09" + integrity sha512-9Muh1H+XB5f5ONmKMayUoTYR1EZwHbwJJ9oZLrKT5yuTf/RLIQ5mYIGsrERquVucJmjmaAW0Y7+6Qo1Ep+5w3Q== + dependencies: + estree-walker "^0.6.0" + micromatch "^3.1.10" + +rollup@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.7.0.tgz#2f5063c0f344f2225d1077655dc54d105a512bb2" integrity sha512-hjuWSCgoQsFSTsmsNP4AH1l1kfkFqW82gW00V9nL81Zr3JtnKn3rvxh18jUAAEMb7qNoHj21PR5SqbK2mhBgMg== From 668e5a1fa900cd329197d5ba3cf065bfc52ef705 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 10:47:18 +0200 Subject: [PATCH 06/16] simplify benchmark build configs --- bench/styles/rollup_config_benchmarks.js | 23 +++++++++------------- bench/versions/rollup_config_benchmarks.js | 21 ++++++++------------ 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/bench/styles/rollup_config_benchmarks.js b/bench/styles/rollup_config_benchmarks.js index cac3ab1865e..e24f175ff45 100644 --- a/bench/styles/rollup_config_benchmarks.js +++ b/bench/styles/rollup_config_benchmarks.js @@ -1,7 +1,7 @@ import fs from 'fs'; import sourcemaps from 'rollup-plugin-sourcemaps'; import replace from 'rollup-plugin-replace'; -import {plugins as basePlugins} from '../../build/rollup_plugins'; +import {plugins} from '../../build/rollup_plugins'; let styles = ['mapbox://styles/mapbox/streets-v10']; @@ -11,17 +11,14 @@ if (process.env.MAPBOX_STYLES) { .map(style => style.match(/\.json$/) ? require(style) : style); } -const plugins = () => basePlugins(true, true).concat( - replace({ - 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), - 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), - 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken), - 'process.env.MAPBOX_STYLES': JSON.stringify(styles), - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) - }) -); +const replaceConfig = { + 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), + 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), + 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken), + 'process.env.MAPBOX_STYLES': JSON.stringify(styles) +}; -const config = [{ +export default [{ input: [`bench/styles/benchmarks.js`, 'src/source/worker.js'], output: { dir: 'rollup/build/benchmarks/styles', @@ -30,7 +27,7 @@ const config = [{ sourcemap: 'inline', chunkFileNames: 'shared.js' }, - plugins: plugins() + plugins: plugins(true, true).concat(replace(replaceConfig)) }, { input: 'rollup/style_benchmarks.js', output: { @@ -43,5 +40,3 @@ const config = [{ treeshake: false, plugins: [sourcemaps()], }]; - -export default config; diff --git a/bench/versions/rollup_config_benchmarks.js b/bench/versions/rollup_config_benchmarks.js index d91428664cf..6ad4861840c 100644 --- a/bench/versions/rollup_config_benchmarks.js +++ b/bench/versions/rollup_config_benchmarks.js @@ -1,18 +1,15 @@ import fs from 'fs'; import sourcemaps from 'rollup-plugin-sourcemaps'; import replace from 'rollup-plugin-replace'; -import {plugins as basePlugins} from '../../build/rollup_plugins'; +import {plugins} from '../../build/rollup_plugins'; -const plugins = () => basePlugins(true, true).concat( - replace({ - 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), - 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), - 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken), - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) - }) -); +const replaceConfig = { + 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), + 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), + 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken) +}; -const config = [{ +export default [{ input: [`bench/versions/benchmarks.js`, 'src/source/worker.js'], output: { dir: 'rollup/build/benchmarks/versions', @@ -21,7 +18,7 @@ const config = [{ sourcemap: 'inline', chunkFileNames: 'shared.js' }, - plugins: plugins() + plugins: plugins(true, true).concat(replace(replaceConfig)) }, { input: 'rollup/benchmarks.js', output: { @@ -34,5 +31,3 @@ const config = [{ treeshake: false, plugins: [sourcemaps()], }]; - -export default config; From cec06e0db255c8f95e324e8889dd6b33385f0bb1 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 11:33:27 +0200 Subject: [PATCH 07/16] move Axis to benchmarks_view --- bench/benchmarks_view.js | 79 ++++++++++++++++++++++++++++++++++++- bench/lib/axis.js | 85 ---------------------------------------- 2 files changed, 78 insertions(+), 86 deletions(-) delete mode 100644 bench/lib/axis.js diff --git a/bench/benchmarks_view.js b/bench/benchmarks_view.js index 8b9bfa85573..1afc57f39b9 100644 --- a/bench/benchmarks_view.js +++ b/bench/benchmarks_view.js @@ -1,12 +1,89 @@ import React from 'react'; import ReactDOM from 'react-dom'; import * as d3 from 'd3'; -import Axis from './lib/axis'; import { kde, probabilitiesOfSuperiority } from './lib/statistics'; const versionColor = d3.scaleOrdinal(['#1b9e77', '#7570b3', '#d95f02']); const formatSample = d3.format(".3r"); +function identity(x) { + return x; +} +function translateX(x) { + return `translate(${x + 0.5},0)`; +} +function translateY(y) { + return `translate(0,${y + 0.5})`; +} +function number(scale) { + return function(d) { + return +scale(d); + }; +} +function center(scale) { + let offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset. + if (scale.round()) offset = Math.round(offset); + return function(d) { + return +scale(d) + offset; + }; +} + +class Axis extends React.Component { + render() { + const scale = this.props.scale; + const orient = this.props.orientation || 'left'; + const tickArguments = this.props.ticks ? [].concat(this.props.ticks) : []; + const tickValues = this.props.tickValues || null; + const tickFormat = this.props.tickFormat || null; + const tickSizeInner = this.props.tickSize || this.props.tickSizeInner || 6; + const tickSizeOuter = this.props.tickSize || this.props.tickSizeOuter || 6; + const tickPadding = this.props.tickPadding || 3; + + const k = orient === 'top' || orient === 'left' ? -1 : 1; + const x = orient === 'left' || orient === 'right' ? 'x' : 'y'; + const transform = orient === 'top' || orient === 'bottom' ? translateX : translateY; + + const values = tickValues == null ? (scale.ticks ? scale.ticks(...tickArguments) : scale.domain()) : tickValues; + const format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat(...tickArguments) : identity) : tickFormat; + const spacing = Math.max(tickSizeInner, 0) + tickPadding; + const range = scale.range(); + const range0 = +range[0] + 0.5; + const range1 = +range[range.length - 1] + 0.5; + const position = (scale.bandwidth ? center : number)(scale.copy()); + + return ( + + + {values.map((d, i) => + + + {format(d)} + + )} + {this.props.children} + + ); + } +} + class StatisticsPlot extends React.Component { constructor(props) { super(props); diff --git a/bench/lib/axis.js b/bench/lib/axis.js deleted file mode 100644 index a1872a5bac1..00000000000 --- a/bench/lib/axis.js +++ /dev/null @@ -1,85 +0,0 @@ -import React from 'react'; - -function identity(x) { - return x; -} - -function translateX(x) { - return `translate(${x + 0.5},0)`; -} - -function translateY(y) { - return `translate(0,${y + 0.5})`; -} - -function number(scale) { - return function(d) { - return +scale(d); - }; -} - -function center(scale) { - let offset = Math.max(0, scale.bandwidth() - 1) / 2; // Adjust for 0.5px offset. - if (scale.round()) offset = Math.round(offset); - return function(d) { - return +scale(d) + offset; - }; -} - -class Axis extends React.Component { - render() { - const scale = this.props.scale; - const orient = this.props.orientation || 'left'; - const tickArguments = this.props.ticks ? [].concat(this.props.ticks) : []; - const tickValues = this.props.tickValues || null; - const tickFormat = this.props.tickFormat || null; - const tickSizeInner = this.props.tickSize || this.props.tickSizeInner || 6; - const tickSizeOuter = this.props.tickSize || this.props.tickSizeOuter || 6; - const tickPadding = this.props.tickPadding || 3; - - const k = orient === 'top' || orient === 'left' ? -1 : 1; - const x = orient === 'left' || orient === 'right' ? 'x' : 'y'; - const transform = orient === 'top' || orient === 'bottom' ? translateX : translateY; - - const values = tickValues == null ? (scale.ticks ? scale.ticks(...tickArguments) : scale.domain()) : tickValues; - const format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat(...tickArguments) : identity) : tickFormat; - const spacing = Math.max(tickSizeInner, 0) + tickPadding; - const range = scale.range(); - const range0 = +range[0] + 0.5; - const range1 = +range[range.length - 1] + 0.5; - const position = (scale.bandwidth ? center : number)(scale.copy()); - - return ( - - - {values.map((d, i) => - - - {format(d)} - - )} - {this.props.children} - - ); - } -} - -export default Axis; From ecab2926fbf0c547dd8790baca69822a15308d90 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 11:35:53 +0200 Subject: [PATCH 08/16] shuffle things around in benchmarks code --- bench/styles/benchmarks.js | 38 +++++++++++---------------- bench/styles/index.html | 1 - bench/versions/benchmarks.js | 50 ++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 52 deletions(-) diff --git a/bench/styles/benchmarks.js b/bench/styles/benchmarks.js index e0ccdac9ea2..88d7836f3b3 100644 --- a/bench/styles/benchmarks.js +++ b/bench/styles/benchmarks.js @@ -4,6 +4,13 @@ import locations from '../lib/style_locations'; import { summaryStatistics, regression } from '../lib/statistics'; import updateUI from '../benchmarks_view'; +import StyleLayerCreate from '../benchmarks/style_layer_create'; +import Validate from '../benchmarks/style_validate'; +import Layout from '../benchmarks/layout'; +import Paint from '../benchmarks/paint'; +import QueryPoint from '../benchmarks/query_point'; +import QueryBox from '../benchmarks/query_box'; + mapboxgl.accessToken = accessToken; const benchmarks = []; @@ -11,14 +18,9 @@ const filter = window.location.hash.substr(1); function register(Benchmark, locations, options) { const name = Benchmark.name; + if (filter && name !== filter) return; - if (filter && name !== filter) - return; - - const benchmark = { - name: Benchmark.name, - versions: [] - }; + const benchmark = { name, versions: [] }; if (options) Object.assign(benchmark, options); @@ -36,13 +38,6 @@ function register(Benchmark, locations, options) { benchmarks.push(benchmark); } -import StyleLayerCreate from '../benchmarks/style_layer_create'; -import Validate from '../benchmarks/style_validate'; -import Layout from '../benchmarks/layout'; -import Paint from '../benchmarks/paint'; -import QueryPoint from '../benchmarks/query_point'; -import QueryBox from '../benchmarks/query_box'; - register(StyleLayerCreate); register(Validate); locations.forEach(location => register(Layout, location.tileID, {location})); @@ -52,15 +47,14 @@ register(QueryBox, locations); import getWorkerPool from '../../src/util/global_worker_pool'; +// Ensure the global worker pool is never drained. Browsers have resource limits +// on the max number of workers that can be created per page. +// We do this async to avoid creating workers before the worker bundle blob +// URL has been set up, which happens after this module is executed. +getWorkerPool().acquire(-1); + let promise = Promise.resolve(); -promise = promise.then(() => { - // Ensure the global worker pool is never drained. Browsers have resource limits - // on the max number of workers that can be created per page. - // We do this async to avoid creating workers before the worker bundle blob - // URL has been set up, which happens after this module is executed. - getWorkerPool().acquire(-1); -}); benchmarks.forEach(bench => { bench.versions.forEach(version => { promise = promise.then(() => { @@ -90,5 +84,3 @@ benchmarks.forEach(bench => { updateUI(benchmarks, true); }); }); - -export default mapboxgl; diff --git a/bench/styles/index.html b/bench/styles/index.html index cb828dde442..7f975b014b7 100644 --- a/bench/styles/index.html +++ b/bench/styles/index.html @@ -8,7 +8,6 @@ - diff --git a/bench/versions/benchmarks.js b/bench/versions/benchmarks.js index f431bafd0ba..641e837be6d 100644 --- a/bench/versions/benchmarks.js +++ b/bench/versions/benchmarks.js @@ -4,18 +4,6 @@ import { summaryStatistics, regression } from '../lib/statistics'; import updateUI from '../benchmarks_view'; import styleLocations from '../lib/style_locations'; -mapboxgl.accessToken = accessToken; - -window.mapboxglBenchmarks = window.mapboxglBenchmarks || {}; - -const version = process.env.BENCHMARK_VERSION; - -function register(benchmark) { - const name = benchmark.constructor.name; - window.mapboxglBenchmarks[name] = window.mapboxglBenchmarks[name] || {}; - window.mapboxglBenchmarks[name][version] = benchmark; -} - import Layout from '../benchmarks/layout'; import LayoutDDS from '../benchmarks/layout_dds'; import SymbolLayout from '../benchmarks/symbol_layout'; @@ -33,6 +21,19 @@ import ExpressionBenchmarks from '../benchmarks/expressions'; import FilterCreate from '../benchmarks/filter_create'; import FilterEvaluate from '../benchmarks/filter_evaluate'; +window.mapboxglBenchmarks = window.mapboxglBenchmarks || {}; + +const version = process.env.BENCHMARK_VERSION; +const filter = window.location.hash.substr(1); + +function register(benchmark) { + const name = benchmark.constructor.name; + if (filter && name !== filter) return; + + window.mapboxglBenchmarks[name] = window.mapboxglBenchmarks[name] || {}; + window.mapboxglBenchmarks[name][version] = benchmark; +} + const style = 'mapbox://styles/mapbox/streets-v10'; const center = [-77.032194, 38.912753]; const zooms = [4, 8, 11, 13, 15, 17]; @@ -57,25 +58,20 @@ register(new FilterEvaluate()); import getWorkerPool from '../../src/util/global_worker_pool'; -const benchmarks = []; -const filter = window.location.hash.substr(1); +// Ensure the global worker pool is never drained. Browsers have resource limits +// on the max number of workers that can be created per page. +// We do this async to avoid creating workers before the worker bundle blob +// URL has been set up, which happens after this module is executed. +getWorkerPool().acquire(-1); -let promise = Promise.resolve(); - -promise = promise.then(() => { - // Ensure the global worker pool is never drained. Browsers have resource limits - // on the max number of workers that can be created per page. - // We do this async to avoid creating workers before the worker bundle blob - // URL has been set up, which happens after this module is executed. - getWorkerPool().acquire(-1); -}); +mapboxgl.accessToken = accessToken; +const benchmarks = []; window.runBenchmarks = () => { - for (const name in window.mapboxglBenchmarks) { - if (filter && name !== filter) - continue; + let promise = Promise.resolve(); + for (const name in window.mapboxglBenchmarks) { const benchmark = { name, versions: [] }; benchmarks.push(benchmark); @@ -117,5 +113,3 @@ window.runBenchmarks = () => { }); } }; - -export default mapboxgl; From 1fe19b9ca58f22bcf0bd063ae16cff1eeadcb57b Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 16:06:44 +0200 Subject: [PATCH 09/16] revert some breaking stuff --- bench/styles/benchmarks.js | 16 +++++++++------- bench/styles/rollup_config_benchmarks.js | 3 ++- bench/versions/benchmarks.js | 17 ++++++++++------- bench/versions/rollup_config_benchmarks.js | 3 ++- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/bench/styles/benchmarks.js b/bench/styles/benchmarks.js index 88d7836f3b3..bfe106fb03e 100644 --- a/bench/styles/benchmarks.js +++ b/bench/styles/benchmarks.js @@ -47,13 +47,13 @@ register(QueryBox, locations); import getWorkerPool from '../../src/util/global_worker_pool'; -// Ensure the global worker pool is never drained. Browsers have resource limits -// on the max number of workers that can be created per page. -// We do this async to avoid creating workers before the worker bundle blob -// URL has been set up, which happens after this module is executed. -getWorkerPool().acquire(-1); - -let promise = Promise.resolve(); +let promise = Promise.resolve().then(() => { + // Ensure the global worker pool is never drained. Browsers have resource limits + // on the max number of workers that can be created per page. + // We do this async to avoid creating workers before the worker bundle blob + // URL has been set up, which happens after this module is executed. + getWorkerPool().acquire(-1); +}); benchmarks.forEach(bench => { bench.versions.forEach(version => { @@ -84,3 +84,5 @@ benchmarks.forEach(bench => { updateUI(benchmarks, true); }); }); + +export default mapboxgl; diff --git a/bench/styles/rollup_config_benchmarks.js b/bench/styles/rollup_config_benchmarks.js index e24f175ff45..f304d8ba030 100644 --- a/bench/styles/rollup_config_benchmarks.js +++ b/bench/styles/rollup_config_benchmarks.js @@ -15,7 +15,8 @@ const replaceConfig = { 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken), - 'process.env.MAPBOX_STYLES': JSON.stringify(styles) + 'process.env.MAPBOX_STYLES': JSON.stringify(styles), + 'process.env.NODE_ENV': JSON.stringify('production') }; export default [{ diff --git a/bench/versions/benchmarks.js b/bench/versions/benchmarks.js index 641e837be6d..126b5047571 100644 --- a/bench/versions/benchmarks.js +++ b/bench/versions/benchmarks.js @@ -58,18 +58,19 @@ register(new FilterEvaluate()); import getWorkerPool from '../../src/util/global_worker_pool'; -// Ensure the global worker pool is never drained. Browsers have resource limits -// on the max number of workers that can be created per page. -// We do this async to avoid creating workers before the worker bundle blob -// URL has been set up, which happens after this module is executed. -getWorkerPool().acquire(-1); - mapboxgl.accessToken = accessToken; +let promise = Promise.resolve().then(() => { + // Ensure the global worker pool is never drained. Browsers have resource limits + // on the max number of workers that can be created per page. + // We do this async to avoid creating workers before the worker bundle blob + // URL has been set up, which happens after this module is executed. + getWorkerPool().acquire(-1); +}); + const benchmarks = []; window.runBenchmarks = () => { - let promise = Promise.resolve(); for (const name in window.mapboxglBenchmarks) { const benchmark = { name, versions: [] }; @@ -113,3 +114,5 @@ window.runBenchmarks = () => { }); } }; + +export default mapboxgl; diff --git a/bench/versions/rollup_config_benchmarks.js b/bench/versions/rollup_config_benchmarks.js index 6ad4861840c..16037fee3d5 100644 --- a/bench/versions/rollup_config_benchmarks.js +++ b/bench/versions/rollup_config_benchmarks.js @@ -6,7 +6,8 @@ import {plugins} from '../../build/rollup_plugins'; const replaceConfig = { 'process.env.BENCHMARK_VERSION': JSON.stringify(process.env.BENCHMARK_VERSION), 'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN), - 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken) + 'process.env.MapboxAccessToken': JSON.stringify(process.env.MapboxAccessToken), + 'process.env.NODE_ENV': JSON.stringify('production') }; export default [{ From 21c769389862e272650cbdb60540b30a927920f8 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 16:19:17 +0200 Subject: [PATCH 10/16] disable minifying bench for now --- bench/styles/rollup_config_benchmarks.js | 2 +- bench/versions/benchmarks.js | 4 ++-- bench/versions/rollup_config_benchmarks.js | 2 +- build/rollup_plugins.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bench/styles/rollup_config_benchmarks.js b/bench/styles/rollup_config_benchmarks.js index f304d8ba030..ce2b72ecc40 100644 --- a/bench/styles/rollup_config_benchmarks.js +++ b/bench/styles/rollup_config_benchmarks.js @@ -28,7 +28,7 @@ export default [{ sourcemap: 'inline', chunkFileNames: 'shared.js' }, - plugins: plugins(true, true).concat(replace(replaceConfig)) + plugins: plugins(false, true).concat(replace(replaceConfig)) }, { input: 'rollup/style_benchmarks.js', output: { diff --git a/bench/versions/benchmarks.js b/bench/versions/benchmarks.js index 126b5047571..03a68a071ed 100644 --- a/bench/versions/benchmarks.js +++ b/bench/versions/benchmarks.js @@ -28,8 +28,6 @@ const filter = window.location.hash.substr(1); function register(benchmark) { const name = benchmark.constructor.name; - if (filter && name !== filter) return; - window.mapboxglBenchmarks[name] = window.mapboxglBenchmarks[name] || {}; window.mapboxglBenchmarks[name][version] = benchmark; } @@ -73,6 +71,8 @@ const benchmarks = []; window.runBenchmarks = () => { for (const name in window.mapboxglBenchmarks) { + if (filter && name !== filter) continue; + const benchmark = { name, versions: [] }; benchmarks.push(benchmark); diff --git a/bench/versions/rollup_config_benchmarks.js b/bench/versions/rollup_config_benchmarks.js index 16037fee3d5..f3ab241ce49 100644 --- a/bench/versions/rollup_config_benchmarks.js +++ b/bench/versions/rollup_config_benchmarks.js @@ -19,7 +19,7 @@ export default [{ sourcemap: 'inline', chunkFileNames: 'shared.js' }, - plugins: plugins(true, true).concat(replace(replaceConfig)) + plugins: plugins(false, true).concat(replace(replaceConfig)) }, { input: 'rollup/benchmarks.js', output: { diff --git a/build/rollup_plugins.js b/build/rollup_plugins.js index eddfc4ee5f3..fef9a4868d1 100644 --- a/build/rollup_plugins.js +++ b/build/rollup_plugins.js @@ -17,8 +17,8 @@ export const plugins = (minified, production) => [ minifyStyleSpec(), json(), glsl('./src/shaders/*.glsl', production), - minified ? terser() : false, buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}), + minified ? terser() : false, production ? unassert() : false, resolve({ browser: true, From 81bac6cf7c0f97a5285c499dd651891080e3b144 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 16:33:42 +0200 Subject: [PATCH 11/16] re-enable bench minification; explicitly name benchmarks --- bench/benchmarks/expressions.js | 18 ++----- bench/benchmarks/layers.js | 33 ++++--------- bench/benchmarks/remove_paint_state.js | 12 ++--- bench/styles/benchmarks.js | 15 +++--- bench/styles/rollup_config_benchmarks.js | 2 +- bench/versions/benchmarks.js | 55 +++++++++++++--------- bench/versions/rollup_config_benchmarks.js | 2 +- 7 files changed, 61 insertions(+), 76 deletions(-) diff --git a/bench/benchmarks/expressions.js b/bench/benchmarks/expressions.js index 01ed5784780..fc2a4e63cac 100644 --- a/bench/benchmarks/expressions.js +++ b/bench/benchmarks/expressions.js @@ -71,7 +71,7 @@ class ExpressionBenchmark extends Benchmark { } } -class FunctionCreate extends ExpressionBenchmark { +export class FunctionCreate extends ExpressionBenchmark { bench() { for (const {rawValue, propertySpec} of this.data) { createFunction(rawValue, propertySpec); @@ -79,7 +79,7 @@ class FunctionCreate extends ExpressionBenchmark { } } -class FunctionEvaluate extends ExpressionBenchmark { +export class FunctionEvaluate extends ExpressionBenchmark { bench() { for (const {compiledFunction} of this.data) { compiledFunction.evaluate({zoom: 0}); @@ -87,7 +87,7 @@ class FunctionEvaluate extends ExpressionBenchmark { } } -class FunctionConvert extends ExpressionBenchmark { +export class FunctionConvert extends ExpressionBenchmark { bench() { for (const {rawValue, propertySpec} of this.data) { convertFunction(rawValue, propertySpec); @@ -95,7 +95,7 @@ class FunctionConvert extends ExpressionBenchmark { } } -class ExpressionCreate extends ExpressionBenchmark { +export class ExpressionCreate extends ExpressionBenchmark { bench() { for (const {rawExpression, propertySpec} of this.data) { createPropertyExpression(rawExpression, propertySpec); @@ -103,18 +103,10 @@ class ExpressionCreate extends ExpressionBenchmark { } } -class ExpressionEvaluate extends ExpressionBenchmark { +export class ExpressionEvaluate extends ExpressionBenchmark { bench() { for (const {compiledExpression} of this.data) { compiledExpression.evaluate({zoom: 0}); } } } - -export default [ - FunctionCreate, - FunctionConvert, - FunctionEvaluate, - ExpressionCreate, - ExpressionEvaluate -]; diff --git a/bench/benchmarks/layers.js b/bench/benchmarks/layers.js index 4cd5bb67e27..a63e25e40ef 100644 --- a/bench/benchmarks/layers.js +++ b/bench/benchmarks/layers.js @@ -15,7 +15,7 @@ function generateLayers(layer) { return generated; } -class LayerBenchmark extends Benchmark { +export class LayerBenchmark extends Benchmark { setup() { return createMap({ zoom: 16, @@ -37,7 +37,7 @@ class LayerBenchmark extends Benchmark { } } -class LayerBackground extends LayerBenchmark { +export class LayerBackground extends LayerBenchmark { constructor() { super(); @@ -50,7 +50,7 @@ class LayerBackground extends LayerBenchmark { } } -class LayerCircle extends LayerBenchmark { +export class LayerCircle extends LayerBenchmark { constructor() { super(); @@ -65,7 +65,7 @@ class LayerCircle extends LayerBenchmark { } } -class LayerFill extends LayerBenchmark { +export class LayerFill extends LayerBenchmark { constructor() { super(); @@ -84,7 +84,7 @@ class LayerFill extends LayerBenchmark { } } -class LayerFillExtrusion extends LayerBenchmark { +export class LayerFillExtrusion extends LayerBenchmark { constructor() { super(); @@ -102,7 +102,7 @@ class LayerFillExtrusion extends LayerBenchmark { } } -class LayerHeatmap extends LayerBenchmark { +export class LayerHeatmap extends LayerBenchmark { setup() { return fetch('/bench/data/naturalearth-land.json') .then(response => response.json()) @@ -144,7 +144,7 @@ class LayerHeatmap extends LayerBenchmark { } } -class LayerHillshade extends LayerBenchmark { +export class LayerHillshade extends LayerBenchmark { constructor() { super(); @@ -164,7 +164,7 @@ class LayerHillshade extends LayerBenchmark { } } -class LayerLine extends LayerBenchmark { +export class LayerLine extends LayerBenchmark { constructor() { super(); @@ -179,7 +179,7 @@ class LayerLine extends LayerBenchmark { } } -class LayerRaster extends LayerBenchmark { +export class LayerRaster extends LayerBenchmark { constructor() { super(); @@ -200,7 +200,7 @@ class LayerRaster extends LayerBenchmark { } } -class LayerSymbol extends LayerBenchmark { +export class LayerSymbol extends LayerBenchmark { constructor() { super(); @@ -218,16 +218,3 @@ class LayerSymbol extends LayerBenchmark { }); } } - - -export default [ - LayerBackground, - LayerCircle, - LayerFill, - LayerFillExtrusion, - LayerHeatmap, - LayerHillshade, - LayerLine, - LayerRaster, - LayerSymbol -]; diff --git a/bench/benchmarks/remove_paint_state.js b/bench/benchmarks/remove_paint_state.js index a67f9b32f6a..191bf243f6c 100644 --- a/bench/benchmarks/remove_paint_state.js +++ b/bench/benchmarks/remove_paint_state.js @@ -68,7 +68,7 @@ class RemovePaintState extends Benchmark { } } -class PropertyLevelRemove extends RemovePaintState { +export class PropertyLevelRemove extends RemovePaintState { bench() { for (let i = 0; i < this.numFeatures; i += 50) { @@ -82,7 +82,7 @@ class PropertyLevelRemove extends RemovePaintState { } } -class FeatureLevelRemove extends RemovePaintState { +export class FeatureLevelRemove extends RemovePaintState { bench() { for (let i = 0; i < this.numFeatures; i += 50) { @@ -96,7 +96,7 @@ class FeatureLevelRemove extends RemovePaintState { } } -class SourceLevelRemove extends RemovePaintState { +export class SourceLevelRemove extends RemovePaintState { bench() { for (let i = 0; i < this.numFeatures; i += 50) { @@ -109,9 +109,3 @@ class SourceLevelRemove extends RemovePaintState { } } - -export default [ - PropertyLevelRemove, - FeatureLevelRemove, - SourceLevelRemove -]; diff --git a/bench/styles/benchmarks.js b/bench/styles/benchmarks.js index bfe106fb03e..e0f5dc3a9aa 100644 --- a/bench/styles/benchmarks.js +++ b/bench/styles/benchmarks.js @@ -16,8 +16,7 @@ mapboxgl.accessToken = accessToken; const benchmarks = []; const filter = window.location.hash.substr(1); -function register(Benchmark, locations, options) { - const name = Benchmark.name; +function register(name, Benchmark, locations, options) { if (filter && name !== filter) return; const benchmark = { name, versions: [] }; @@ -38,12 +37,12 @@ function register(Benchmark, locations, options) { benchmarks.push(benchmark); } -register(StyleLayerCreate); -register(Validate); -locations.forEach(location => register(Layout, location.tileID, {location})); -locations.forEach(location => register(Paint, [location], {location})); -register(QueryPoint, locations); -register(QueryBox, locations); +register('StyleLayerCreate', StyleLayerCreate); +register('Validate', Validate); +locations.forEach(location => register('Layout', Layout, location.tileID, {location})); +locations.forEach(location => register('Paint', Paint, [location], {location})); +register('QueryPoint', QueryPoint, locations); +register('QueryBox', QueryBox, locations); import getWorkerPool from '../../src/util/global_worker_pool'; diff --git a/bench/styles/rollup_config_benchmarks.js b/bench/styles/rollup_config_benchmarks.js index ce2b72ecc40..f304d8ba030 100644 --- a/bench/styles/rollup_config_benchmarks.js +++ b/bench/styles/rollup_config_benchmarks.js @@ -28,7 +28,7 @@ export default [{ sourcemap: 'inline', chunkFileNames: 'shared.js' }, - plugins: plugins(false, true).concat(replace(replaceConfig)) + plugins: plugins(true, true).concat(replace(replaceConfig)) }, { input: 'rollup/style_benchmarks.js', output: { diff --git a/bench/versions/benchmarks.js b/bench/versions/benchmarks.js index 03a68a071ed..0836c5ce38a 100644 --- a/bench/versions/benchmarks.js +++ b/bench/versions/benchmarks.js @@ -10,14 +10,14 @@ import SymbolLayout from '../benchmarks/symbol_layout'; import WorkerTransfer from '../benchmarks/worker_transfer'; import Paint from '../benchmarks/paint'; import PaintStates from '../benchmarks/paint_states'; -import RemovePaintStateBenchmarks from '../benchmarks/remove_paint_state'; -import LayerBenchmarks from '../benchmarks/layers'; +import {PropertyLevelRemove, FeatureLevelRemove, SourceLevelRemove} from '../benchmarks/remove_paint_state'; +import {LayerBackground, LayerCircle, LayerFill, LayerFillExtrusion, LayerHeatmap, LayerHillshade, LayerLine, LayerRaster, LayerSymbol} from '../benchmarks/layers'; import Load from '../benchmarks/map_load'; import Validate from '../benchmarks/style_validate'; import StyleLayerCreate from '../benchmarks/style_layer_create'; import QueryPoint from '../benchmarks/query_point'; import QueryBox from '../benchmarks/query_box'; -import ExpressionBenchmarks from '../benchmarks/expressions'; +import {FunctionCreate, FunctionEvaluate, FunctionConvert, ExpressionCreate, ExpressionEvaluate} from '../benchmarks/expressions'; import FilterCreate from '../benchmarks/filter_create'; import FilterEvaluate from '../benchmarks/filter_evaluate'; @@ -26,8 +26,7 @@ window.mapboxglBenchmarks = window.mapboxglBenchmarks || {}; const version = process.env.BENCHMARK_VERSION; const filter = window.location.hash.substr(1); -function register(benchmark) { - const name = benchmark.constructor.name; +function register(name, benchmark) { window.mapboxglBenchmarks[name] = window.mapboxglBenchmarks[name] || {}; window.mapboxglBenchmarks[name][version] = benchmark; } @@ -37,22 +36,36 @@ const center = [-77.032194, 38.912753]; const zooms = [4, 8, 11, 13, 15, 17]; const locations = zooms.map(zoom => ({center, zoom})); -register(new Paint(style, locations)); -register(new QueryPoint(style, locations)); -register(new QueryBox(style, locations)); -register(new Layout(style)); -register(new Validate(style)); -register(new StyleLayerCreate(style)); -ExpressionBenchmarks.forEach((Bench) => register(new Bench(style))); -register(new WorkerTransfer(style)); -register(new PaintStates(center)); -RemovePaintStateBenchmarks.forEach((Bench) => register(new Bench(center))); -LayerBenchmarks.forEach((Bench) => register(new Bench())); -register(new Load()); -register(new LayoutDDS()); -register(new SymbolLayout(style, styleLocations.map(location => location.tileID[0]))); -register(new FilterCreate()); -register(new FilterEvaluate()); +register('Paint', new Paint(style, locations)); +register('QueryPoint', new QueryPoint(style, locations)); +register('QueryBox', new QueryBox(style, locations)); +register('Layout', new Layout(style)); +register('Validate', new Validate(style)); +register('StyleLayerCreate', new StyleLayerCreate(style)); +register('FunctionCreate', new FunctionCreate(style)); +register('FunctionEvaluate', new FunctionEvaluate(style)); +register('FunctionConvert', new FunctionConvert(style)); +register('ExpressionCreate', new ExpressionCreate(style)); +register('ExpressionEvaluate', new ExpressionEvaluate(style)); +register('WorkerTransfer', new WorkerTransfer(style)); +register('PaintStates', new PaintStates(center)); +register('PropertyLevelRemove', new PropertyLevelRemove(center)); +register('FeatureLevelRemove', new FeatureLevelRemove(center)); +register('SourceLevelRemove', new SourceLevelRemove(center)); +register('LayerBackground', new LayerBackground()); +register('LayerCircle', new LayerCircle()); +register('LayerFill', new LayerFill()); +register('LayerFillExtrusion', new LayerFillExtrusion()); +register('LayerHeatmap', new LayerHeatmap()); +register('LayerHillshade', new LayerHillshade()); +register('LayerLine', new LayerLine()); +register('LayerRaster', new LayerRaster()); +register('LayerSymbol', new LayerSymbol()); +register('Load', new Load()); +register('LayoutDDS', new LayoutDDS()); +register('SymbolLayout', new SymbolLayout(style, styleLocations.map(location => location.tileID[0]))); +register('FilterCreate', new FilterCreate()); +register('FilterEvaluate', new FilterEvaluate()); import getWorkerPool from '../../src/util/global_worker_pool'; diff --git a/bench/versions/rollup_config_benchmarks.js b/bench/versions/rollup_config_benchmarks.js index f3ab241ce49..16037fee3d5 100644 --- a/bench/versions/rollup_config_benchmarks.js +++ b/bench/versions/rollup_config_benchmarks.js @@ -19,7 +19,7 @@ export default [{ sourcemap: 'inline', chunkFileNames: 'shared.js' }, - plugins: plugins(false, true).concat(replace(replaceConfig)) + plugins: plugins(true, true).concat(replace(replaceConfig)) }, { input: 'rollup/benchmarks.js', output: { From a35e984b6158e6267d9f519977e6f27bf8afc605 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 22 Mar 2019 18:55:37 +0200 Subject: [PATCH 12/16] cut out UI logic from benchmark builds, reintroduce benchmarks_view --- .gitignore | 8 +-- bench/benchmarks/layout.js | 12 ++--- bench/benchmarks_view.js | 52 ++++++++++++++++++- bench/rollup_config_benchmarks_view.js | 14 ++++++ bench/styles/benchmarks.js | 70 ++++++-------------------- bench/styles/index.html | 4 ++ bench/versions/benchmarks.js | 64 +++-------------------- bench/versions/index.html | 26 ++++++++-- package.json | 3 +- 9 files changed, 117 insertions(+), 136 deletions(-) create mode 100644 bench/rollup_config_benchmarks_view.js diff --git a/.gitignore b/.gitignore index 33732819097..24de88105db 100644 --- a/.gitignore +++ b/.gitignore @@ -11,12 +11,8 @@ coverage flow-coverage .DS_Store .nyc_output -bench/versions/benchmarks_generated.js -bench/versions/benchmarks_generated.js.map -bench/styles/benchmarks_generated.js -bench/styles/benchmarks_generated.js.map -debug/access_token_generated.js -debug/style_property_editor_generated.js +*_generated.js +*_generated.js.map test/integration/**/index*.html test/integration/**/actual.png test/integration/**/actual.json diff --git a/bench/benchmarks/layout.js b/bench/benchmarks/layout.js index 32554f9c3ee..debd61d8663 100644 --- a/bench/benchmarks/layout.js +++ b/bench/benchmarks/layout.js @@ -10,16 +10,12 @@ export default class Layout extends Benchmark { tiles: Array<{tileID: OverscaledTileID, buffer: ArrayBuffer}>; parser: TileParser; style: string | StyleSpecification; - locations: Array; + tileIDs: Array; - constructor(style: string | StyleSpecification, locations: ?Array) { + constructor(style: string | StyleSpecification, tileIDs: ?Array) { super(); this.style = style; - this.locations = locations || this.tileIDs(); - } - - tileIDs(): Array { - return [ + this.tileIDs = tileIDs || [ new OverscaledTileID(12, 0, 12, 655, 1583), new OverscaledTileID(8, 0, 8, 40, 98), new OverscaledTileID(4, 0, 4, 3, 6), @@ -34,7 +30,7 @@ export default class Layout extends Benchmark { return this.parser.setup(); }) .then(() => { - return Promise.all(this.locations.map(tileID => this.parser.fetchTile(tileID))); + return Promise.all(this.tileIDs.map(tileID => this.parser.fetchTile(tileID))); }) .then((tiles) => { this.tiles = tiles; diff --git a/bench/benchmarks_view.js b/bench/benchmarks_view.js index 1afc57f39b9..b6ce6a080c8 100644 --- a/bench/benchmarks_view.js +++ b/bench/benchmarks_view.js @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import * as d3 from 'd3'; -import { kde, probabilitiesOfSuperiority } from './lib/statistics'; +import { kde, probabilitiesOfSuperiority, summaryStatistics, regression } from './lib/statistics'; const versionColor = d3.scaleOrdinal(['#1b9e77', '#7570b3', '#d95f02']); const formatSample = d3.format(".3r"); @@ -469,7 +469,7 @@ class BenchmarksTable extends React.Component { } } -export default function updateUI(benchmarks, finished) { +function updateUI(benchmarks, finished) { finished = !!finished; ReactDOM.render( @@ -477,3 +477,51 @@ export default function updateUI(benchmarks, finished) { document.getElementById('benchmarks') ); } + +export function run(benchmarks) { + const filter = window.location.hash.substr(1); + if (filter) benchmarks = benchmarks.filter(({name}) => name === filter); + + for (const benchmark of benchmarks) { + for (const version of benchmark.versions) { + version.status = 'waiting'; + version.logs = []; + version.samples = []; + version.summary = {}; + } + } + + updateUI(benchmarks); + + let promise = Promise.resolve(); + + benchmarks.forEach(bench => { + bench.versions.forEach(version => { + promise = promise.then(() => { + version.status = 'running'; + updateUI(benchmarks); + + return version.bench.run() + .then(measurements => { + // scale measurements down by iteration count, so that + // they represent (average) time for a single iteration + const samples = measurements.map(({time, iterations}) => time / iterations); + version.status = 'ended'; + version.samples = samples; + version.summary = summaryStatistics(samples); + version.regression = regression(measurements); + updateUI(benchmarks); + }) + .catch(error => { + version.status = 'errored'; + version.error = error; + updateUI(benchmarks); + }); + }); + }); + }); + + promise = promise.then(() => { + updateUI(benchmarks, true); + }); +} diff --git a/bench/rollup_config_benchmarks_view.js b/bench/rollup_config_benchmarks_view.js new file mode 100644 index 00000000000..4a801e8a403 --- /dev/null +++ b/bench/rollup_config_benchmarks_view.js @@ -0,0 +1,14 @@ +import replace from 'rollup-plugin-replace'; +import {plugins} from '../build/rollup_plugins'; + +export default { + input: 'bench/benchmarks_view.js', + output: { + name: 'Benchmarks', + file: 'bench/benchmarks_view_generated.js', + format: 'umd', + indent: false, + sourcemap: true + }, + plugins: plugins(true, true).concat(replace({'process.env.NODE_ENV': '"production"'})) +}; diff --git a/bench/styles/benchmarks.js b/bench/styles/benchmarks.js index e0f5dc3a9aa..05f3905cba7 100644 --- a/bench/styles/benchmarks.js +++ b/bench/styles/benchmarks.js @@ -1,8 +1,6 @@ import mapboxgl from '../../src'; import accessToken from '../lib/access_token'; import locations from '../lib/style_locations'; -import { summaryStatistics, regression } from '../lib/statistics'; -import updateUI from '../benchmarks_view'; import StyleLayerCreate from '../benchmarks/style_layer_create'; import Validate from '../benchmarks/style_validate'; @@ -11,42 +9,32 @@ import Paint from '../benchmarks/paint'; import QueryPoint from '../benchmarks/query_point'; import QueryBox from '../benchmarks/query_box'; -mapboxgl.accessToken = accessToken; - -const benchmarks = []; -const filter = window.location.hash.substr(1); +import getWorkerPool from '../../src/util/global_worker_pool'; -function register(name, Benchmark, locations, options) { - if (filter && name !== filter) return; +mapboxgl.accessToken = accessToken; - const benchmark = { name, versions: [] }; +const benchmarks = window.benchmarks = []; - if (options) Object.assign(benchmark, options); +function register(name, Benchmark, locations, location) { + const versions = []; - process.env.MAPBOX_STYLES.forEach(style => { - const { name } = style; - benchmark.versions.push({ - name: name ? name : style.replace('mapbox://styles/', ''), - bench: new Benchmark(style, locations), - status: 'waiting', - logs: [], - samples: [], - summary: {} + for (const style of process.env.MAPBOX_STYLES) { + versions.push({ + name: style.name || style.replace('mapbox://styles/', ''), + bench: new Benchmark(style, locations) }); - }); - benchmarks.push(benchmark); + } + benchmarks.push({name, versions, location}); } register('StyleLayerCreate', StyleLayerCreate); register('Validate', Validate); -locations.forEach(location => register('Layout', Layout, location.tileID, {location})); -locations.forEach(location => register('Paint', Paint, [location], {location})); +locations.forEach(location => register('Layout', Layout, location.tileID, location)); +locations.forEach(location => register('Paint', Paint, [location], location)); register('QueryPoint', QueryPoint, locations); register('QueryBox', QueryBox, locations); -import getWorkerPool from '../../src/util/global_worker_pool'; - -let promise = Promise.resolve().then(() => { +Promise.resolve().then(() => { // Ensure the global worker pool is never drained. Browsers have resource limits // on the max number of workers that can be created per page. // We do this async to avoid creating workers before the worker bundle blob @@ -54,34 +42,4 @@ let promise = Promise.resolve().then(() => { getWorkerPool().acquire(-1); }); -benchmarks.forEach(bench => { - bench.versions.forEach(version => { - promise = promise.then(() => { - version.status = 'running'; - updateUI(benchmarks); - - return version.bench.run() - .then(measurements => { - // scale measurements down by iteration count, so that - // they represent (average) time for a single iteration - const samples = measurements.map(({time, iterations}) => time / iterations); - version.status = 'ended'; - version.samples = samples; - version.summary = summaryStatistics(samples); - version.regression = regression(measurements); - updateUI(benchmarks); - }) - .catch(error => { - version.status = 'errored'; - version.error = error; - updateUI(benchmarks); - }); - }); - }); - - promise = promise.then(() => { - updateUI(benchmarks, true); - }); -}); - export default mapboxgl; diff --git a/bench/styles/index.html b/bench/styles/index.html index 7f975b014b7..4344efa5444 100644 --- a/bench/styles/index.html +++ b/bench/styles/index.html @@ -13,6 +13,10 @@
+ + diff --git a/bench/versions/benchmarks.js b/bench/versions/benchmarks.js index 0836c5ce38a..5e8078e897a 100644 --- a/bench/versions/benchmarks.js +++ b/bench/versions/benchmarks.js @@ -1,7 +1,5 @@ import mapboxgl from '../../src'; import accessToken from '../lib/access_token'; -import { summaryStatistics, regression } from '../lib/statistics'; -import updateUI from '../benchmarks_view'; import styleLocations from '../lib/style_locations'; import Layout from '../benchmarks/layout'; @@ -21,10 +19,13 @@ import {FunctionCreate, FunctionEvaluate, FunctionConvert, ExpressionCreate, Exp import FilterCreate from '../benchmarks/filter_create'; import FilterEvaluate from '../benchmarks/filter_evaluate'; -window.mapboxglBenchmarks = window.mapboxglBenchmarks || {}; +import getWorkerPool from '../../src/util/global_worker_pool'; + +mapboxgl.accessToken = accessToken; + +window.mapboxglBenchmarks = window.mapboxglBenchmarks || []; const version = process.env.BENCHMARK_VERSION; -const filter = window.location.hash.substr(1); function register(name, benchmark) { window.mapboxglBenchmarks[name] = window.mapboxglBenchmarks[name] || {}; @@ -67,11 +68,7 @@ register('SymbolLayout', new SymbolLayout(style, styleLocations.map(location => register('FilterCreate', new FilterCreate()); register('FilterEvaluate', new FilterEvaluate()); -import getWorkerPool from '../../src/util/global_worker_pool'; - -mapboxgl.accessToken = accessToken; - -let promise = Promise.resolve().then(() => { +Promise.resolve().then(() => { // Ensure the global worker pool is never drained. Browsers have resource limits // on the max number of workers that can be created per page. // We do this async to avoid creating workers before the worker bundle blob @@ -79,53 +76,4 @@ let promise = Promise.resolve().then(() => { getWorkerPool().acquire(-1); }); -const benchmarks = []; - -window.runBenchmarks = () => { - - for (const name in window.mapboxglBenchmarks) { - if (filter && name !== filter) continue; - - const benchmark = { name, versions: [] }; - benchmarks.push(benchmark); - - for (const test in window.mapboxglBenchmarks[name]) { - const version = { - name: test, - status: 'waiting', - logs: [], - samples: [], - summary: {} - }; - benchmark.versions.push(version); - - promise = promise.then(() => { - version.status = 'running'; - updateUI(benchmarks); - - return window.mapboxglBenchmarks[name][test].run() - .then(measurements => { - // scale measurements down by iteration count, so that - // they represent (average) time for a single iteration - const samples = measurements.map(({time, iterations}) => time / iterations); - version.status = 'ended'; - version.samples = samples; - version.summary = summaryStatistics(samples); - version.regression = regression(measurements); - updateUI(benchmarks); - }) - .catch(error => { - version.status = 'errored'; - version.error = error; - updateUI(benchmarks); - }); - }); - } - - promise = promise.then(() => { - updateUI(benchmarks, true); - }); - } -}; - export default mapboxgl; diff --git a/bench/versions/index.html b/bench/versions/index.html index cb338dd7103..2cfe9811552 100644 --- a/bench/versions/index.html +++ b/bench/versions/index.html @@ -8,11 +8,12 @@ - +
+