-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2327 from mapbox/bench-geojson-rendering
Make benchmarks navigable and add fps tests for setData
- Loading branch information
Showing
16 changed files
with
207 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
var Evented = require('../../js/util/evented'); | ||
var util = require('../../js/util/util'); | ||
var formatNumber = require('../lib/format_number'); | ||
var setDataPerf = require('../lib/set_data_perf'); | ||
var setupGeoJSONMap = require('../lib/setup_geojson_map'); | ||
|
||
var featureCollection = require('../data/naturalearth-land.json'); | ||
|
||
module.exports = function(options) { | ||
var evented = util.extend({}, Evented); | ||
|
||
var map = options.createMap({ | ||
width: 1024, | ||
height: 768, | ||
zoom: 5, | ||
center: [-77.032194, 38.912753], | ||
style: 'mapbox://styles/mapbox/bright-v8' | ||
}); | ||
|
||
map.on('load', function() { | ||
map = setupGeoJSONMap(map); | ||
|
||
var source = map.getSource('geojson'); | ||
|
||
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}); | ||
}); | ||
}); | ||
|
||
return evented; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
var Evented = require('../../js/util/evented'); | ||
var util = require('../../js/util/util'); | ||
var formatNumber = require('../lib/format_number'); | ||
var setDataPerf = require('../lib/set_data_perf'); | ||
var setupGeoJSONMap = require('../lib/setup_geojson_map'); | ||
|
||
var featureCollection = { | ||
'type': 'FeatureCollection', | ||
'features': [{ | ||
'type': 'Feature', | ||
'properties': {}, | ||
'geometry': { | ||
'type': 'Point', | ||
'coordinates': [ -77.032194, 38.912753 ] | ||
} | ||
}] | ||
}; | ||
|
||
module.exports = function(options) { | ||
var evented = util.extend({}, Evented); | ||
|
||
var map = options.createMap({ | ||
width: 1024, | ||
height: 768, | ||
zoom: 5, | ||
center: [-77.032194, 38.912753], | ||
style: 'mapbox://styles/mapbox/bright-v8' | ||
}); | ||
|
||
map.on('load', function() { | ||
map = setupGeoJSONMap(map); | ||
|
||
var source = map.getSource('geojson'); | ||
|
||
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}); | ||
}); | ||
}); | ||
|
||
return evented; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
bench/query_point_benchmark.js → bench/benchmarks/query_point.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = function measureFramerate(duration, callback) { | ||
var startTime = performance.now(); | ||
var count = 0; | ||
|
||
requestAnimationFrame(function onAnimationFrame() { | ||
count++; | ||
if (performance.now() < startTime + duration) { | ||
requestAnimationFrame(onAnimationFrame); | ||
} else { | ||
var endTime = performance.now(); | ||
callback(null, count / (endTime - startTime) * 1000); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
var NUM_TILES = 6; | ||
|
||
module.exports = function(source, numCalls, geojson, cb) { | ||
var tileCount = 0; | ||
var startTime = null; | ||
var times = []; | ||
|
||
source.on('tile.load', function tileCounter() { | ||
tileCount++; | ||
if (tileCount === NUM_TILES) { | ||
tileCount = 0; | ||
times.push(performance.now() - startTime); | ||
|
||
if (times.length < numCalls) { | ||
startTime = performance.now(); | ||
source.setData(geojson); | ||
} else { | ||
var avgTileTime = times.reduce((v, t) => v + t, 0) / times.length; | ||
source.off('tile.load', tileCounter); | ||
cb(null, avgTileTime); | ||
} | ||
} | ||
}); | ||
|
||
startTime = performance.now(); | ||
source.setData(geojson); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
module.exports = function(map) { | ||
map.addSource('geojson', { | ||
'type': 'geojson', | ||
'data': { | ||
'type': 'FeatureCollection', | ||
'features': [] | ||
} | ||
}); | ||
|
||
map.addLayer({ | ||
'id': 'geojson-polygon', | ||
'source': 'geojson', | ||
'type': 'fill', | ||
'filter': ['all', ['==', '$type', 'Polygon']], | ||
'paint': { | ||
'fill-color': '#000000', | ||
'fill-opacity': 0.25 | ||
} | ||
}); | ||
|
||
map.addLayer({ | ||
'id': 'geojson-point', | ||
'source': 'geojson', | ||
'type': 'circle', | ||
'filter': ['all', ['==', '$type', 'Point']], | ||
'paint': { | ||
'circle-radius': 5, | ||
'circle-color': '#000000' | ||
} | ||
}); | ||
|
||
return map; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters