Skip to content

Commit

Permalink
Merge branch 'master' into shelf-pack-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bhousel committed Aug 11, 2016
2 parents 24ed82f + a84083b commit 793dd25
Show file tree
Hide file tree
Showing 41 changed files with 716 additions and 335 deletions.
15 changes: 8 additions & 7 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"extends": "mourner",
"rules": {
"object-curly-spacing": "off",
"key-spacing": "off",
"array-bracket-spacing": "off",
"space-before-function-paren": "off",
"quotes": "off",
"no-eq-null": "off",
"block-scoped-var": "error",
"consistent-return": "off",
"global-require": "off",
"block-scoped-var": "error",
"no-warning-comments": "error"
"key-spacing": "off",
"no-eq-null": "off",
"no-new": "off",
"no-warning-comments": "error",
"object-curly-spacing": "off",
"quotes": "off",
"space-before-function-paren": "off",
},
"env": {
"es6": true
Expand Down
13 changes: 13 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--
Hello! Thanks for contributing. To help your PR be most easily reviewed, please complete
the following checklist:
-->

## Checklist

- [ ] briefly describe the changes in this PR
- [ ] write tests for all new functionality
- [ ] [document any changes or additions to public APIs](https://github.com/mapbox/mapbox-gl-js/blob/master/docs/README.md)
- [ ] [post scores for all benchmarks on your branch and `master`](https://github.com/mapbox/mapbox-gl-js/blob/master/bench/README.md#running-benchmarks)
- [ ] [do a quick sanity check on the debug page](https://github.com/mapbox/mapbox-gl-js/blob/master/CONTRIBUTING.md#serving-the-debug-page)
- [ ] get a PR review :+1: / :-1:
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ These projects are written and maintained by the GL JS community. Feel free to o
- [Typescript Interface Definition](https://github.com/Smartrak/mapbox-gl-js-typescript)
- [Webtoolkit Integration](https://github.com/yvanvds/wtMapbox)

## Using Mapbox GL JS with [CSP](https://developer.mozilla.org/en-US/docs/Web/Security/CSP)

You may use a Content Security Policy to restrict the resources your page has
access to, as a way of guarding against Cross-Site Scripting and other types of
attacks. If you do, Mapbox GL JS requires the following directives:

```
child-src blob: ;
img-src data: blob: ;
script-src 'unsafe-eval' ;
```

Requesting styles from Mapbox or other services will require additional
directives. For Mapbox, you can use this `connect-src` setting:

```
connect-src https://*.tiles.mapbox.com https://api.mapbox.com
```

## Contributing to Mapbox GL JS

See [CONTRIBUTING.md](https://github.com/mapbox/mapbox-gl-js/blob/master/CONTRIBUTING.md).
7 changes: 7 additions & 0 deletions bench/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
}
}
7 changes: 3 additions & 4 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

Benchmarks help us catch performance regressions and improve performance.

## Running a Benchmark
## Running Benchmarks

Start the benchmark server

```bash
MAPBOX_ACCESS_TOKEN={YOUR MAPBOX ACCESS TOKEN} npm start
```

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

- **buffer benchmark** http://localhost:9966/bench/buffer
- **fps benchmark** http://localhost:9966/bench/fps
To run a specific benchmark, append its name to the url, for example [`http://localhost:9966/bench/buffer`](http://localhost:9966/bench/buffer).

## Writing a Benchmark

Expand Down
2 changes: 1 addition & 1 deletion bench/benchmarks/fps.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function(options) {
evented.fire('error', { error: err });
} else {
evented.fire('end', {
message: formatNumber(fps) + ' frames per second',
message: formatNumber(fps) + ' fps',
score: 1 / fps
});
}
Expand Down
9 changes: 4 additions & 5 deletions bench/benchmarks/frame_duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ module.exports = function(options) {
measureFrameTime(options, zooms[index], function(err_, result) {
results[index] = result;
evented.fire('log', {
message: formatNumber(result.sum / result.count * 10) / 10 + ' ms per frame at zoom ' + zooms[index] + '. ' +
formatNumber(result.countAbove16 / result.count * 100) + '% of frames took longer than 16ms.'
message: formatNumber(result.sum / result.count * 10) / 10 + ' ms, ' +
formatNumber(result.countAbove16 / result.count * 100) + '% > 16 ms at zoom ' + zooms[index]
});
callback();
});
}

function done() {
document.getElementById('map').remove();

var sum = 0;
var count = 0;
var countAbove16 = 0;
Expand All @@ -50,7 +48,7 @@ module.exports = function(options) {
countAbove16 += result.countAbove16;
}
evented.fire('end', {
message: formatNumber(sum / count * 10) / 10 + ' ms per frame. ' + formatNumber(countAbove16 / count * 100) + '% of frames took longer than 16ms.',
message: formatNumber(sum / count * 10) / 10 + ' ms, ' + formatNumber(countAbove16 / count * 100) + '% > 16ms',
score: sum / count
});
}
Expand Down Expand Up @@ -96,6 +94,7 @@ function measureFrameTime(options, zoom, callback) {
if (frameEnd - start > DURATION_MILLISECONDS) {
map.repaint = false;
map.remove();
map.getContainer().remove();
callback(undefined, {
sum: sum,
count: count,
Expand Down
2 changes: 1 addition & 1 deletion bench/benchmarks/geojson_setdata_large.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function(options) {
evented.fire('log', {message: 'loading large feature collection'});
setDataPerf(source, 50, featureCollection, function(err, ms) {
if (err) return evented.fire('error', {error: err});
evented.fire('end', {message: 'average load time: ' + formatNumber(ms) + ' ms', score: ms});
evented.fire('end', {message: formatNumber(ms) + ' ms', score: ms});
});
});

Expand Down
2 changes: 1 addition & 1 deletion bench/benchmarks/geojson_setdata_small.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(options) {
evented.fire('log', {message: 'loading small feature collection'});
setDataPerf(source, 50, featureCollection, function(err, ms) {
if (err) return evented.fire('error', {error: err});
evented.fire('end', {message: 'average load time: ' + formatNumber(ms) + ' ms', score: ms});
evented.fire('end', {message: formatNumber(ms) + ' ms', score: ms});
});
});

Expand Down
7 changes: 3 additions & 4 deletions bench/benchmarks/query_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ module.exports = function(options) {
center: [-77.032194, 38.912753],
style: 'mapbox://styles/mapbox/streets-v9'
});
document.getElementById('map').style.display = 'none';
map.getContainer().style.display = 'none';

map.on('load', function() {

var zoomSum = 0;
var zoomCount = 0;
asyncSeries(numSamples, function(n, callback) {
var start = performance.now();
map.queryRenderedFeatures();
map.queryRenderedFeatures({});
var duration = performance.now() - start;
sum += duration;
count++;
Expand All @@ -45,7 +45,7 @@ module.exports = function(options) {
callback();
}, function() {
evented.fire('log', {
message: 'zoom ' + zoomLevel + ' average: ' + (zoomSum / zoomCount).toFixed(2) + ' ms'
message: (zoomSum / zoomCount).toFixed(2) + ' ms at zoom ' + zoomLevel
});
callback();
});
Expand Down Expand Up @@ -80,4 +80,3 @@ function asyncSeries(times, work, callback) {
callback();
}
}

7 changes: 3 additions & 4 deletions bench/benchmarks/query_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(options) {
center: [-77.032194, 38.912753],
style: 'mapbox://styles/mapbox/streets-v9'
});
document.getElementById('map').style.display = 'none';
map.getContainer().style.display = 'none';

map.on('load', function() {

Expand All @@ -46,7 +46,7 @@ module.exports = function(options) {
asyncSeries(queryPoints.length, function(n, callback) {
var queryPoint = queryPoints[queryPoints.length - n];
var start = performance.now();
map.queryRenderedFeatures(queryPoint);
map.queryRenderedFeatures(queryPoint, {});
var duration = performance.now() - start;
sum += duration;
count++;
Expand All @@ -55,7 +55,7 @@ module.exports = function(options) {
callback();
}, function() {
evented.fire('log', {
message: 'zoom ' + zoomLevel + ' average: ' + (zoomSum / zoomCount).toFixed(2) + ' ms'
message: (zoomSum / zoomCount).toFixed(2) + ' ms at zoom ' + zoomLevel
});
callback();
});
Expand Down Expand Up @@ -90,4 +90,3 @@ function asyncSeries(times, work, callback) {
callback();
}
}

26 changes: 1 addition & 25 deletions bench/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,10 @@

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

<style>
#benchmarks {
width: 100%;
margin: 25px auto;
text-align: center;
}
#benchmarks a {
margin: 5px;
}
#logs {
margin: 25px auto;
width: 600px;
}
.log {
padding: 15px 20px;
}
#map {
margin: 25px auto;
display: none;
}
</style>
</head>

<body class="prose">
<body>
<div id="benchmarks"></div>
<div id="logs"></div>
<div id="map"></div>
<script src="/bench/index.js"></script>
</body>

Expand Down
Loading

0 comments on commit 793dd25

Please sign in to comment.