Количество | Общее время, мс | Время на один элемент, мс |
---|---|---|
HTML:
<ya-map ya-zoom="10" ya-center="{{ center }}"> <ya-toolbar ya-name="smallZoomControl" ya-options="{right: 5, top: 75}"></ya-toolbar> <ya-cluster> <ya-geo-object ng-repeat="o in geoObjects" ya-source="o" ya-after-init="test($last)"></ya-geo-object> </ya-cluster> </ya-map>
javascript:
$scope.count = 500; $scope.results = []; $scope.center = [37.611619,55.819543]; var start, end; function getRandomCoordinates () { return [ $scope.center[0] + 5.5 * Math.random() * Math.random() * ( Math.random() < 0.5 ? -1 : 1), $scope.center[1] + 5.5 * Math.random() * Math.random() * ( Math.random() < 0.5 ? -1 : 1) ]; } $scope.run = function(){ var geos = []; for (var i = 0; i < $scope.count; i++) { geos.push({ geometry:{ type:'Point', coordinates:getRandomCoordinates() } }); } start = new Date(); $scope.geoObjects = geos; }; $scope.test = function(last){ if(last){ end=new Date(); var dur = end.getTime() - start.getTime(); $scope.results.push({ count:$scope.count, duration: dur, forOne:dur/$scope.count }); } };