jeudi 26 février 2015

OpenLayers measure map rendering time


I am using OpenLayers version 3 (answers with ver 2 are also OK) and want to measure how long it takes to render the vector layer. So, I have a vector layer with features:



var vectorLayer = new ol.layer.Vector({
source: vectorSource
});


And my map object:



var map = new ol.Map({
renderer: 'canvas',
target: document.getElementById('map'),
view: new ol.View({
center: [550000, 6520000],
resolution: 500,
minZoom: 1,
maxZoom: 10,
zoom: 1,
resolutions: [500.0, 250.0, 125.0, 62.5, 31.25, 15.625, 7.8125, 3.90625, 1.953125, 0.9765625, 0.48828125],
projection: projection
})
});


I want to measure how long it takes to render all features from the layer. If I do like this



var start=performance.now();
map.addLayer(vectorLayer);
var time=performance.now()-start;
console.log(time)


then I see time in console much much earlier than points on map. I want to see the time right after all points are rendered. How can I do that?





Aucun commentaire:

Enregistrer un commentaire