原文:【百度地图API】多家地图API内存消耗对比测验(带源码)

任务描述:

啊,美妙的春节结束了。酸奶小妹和妈妈的山西平遥之旅也宣告成功!距离平遥古城7km,有一个同样身为“世界文化遗产”的寺庙,叫做“双林寺”。双林寺的精致、纯木质结构、保存完好等特点,让我不由得为之一振。这让我想到了,万事万物都需要对比,“取其精华,去其糟粕”。

双林寺如是,API也如是。这不,上班第一天,我就迫不及待地做起了API性能测试。

如何实现:

使用不同家的API,分别以随机新增覆盖物为测试用例,观察内存消耗变化。

需要使用到不同家API来分别写测试用例。测试工具为IE6。

目前,有baidu、google、mapbar和mapabc。(2011-02-09 15:14更新,添加51地图)

图示:

说明:

在这里,我只列举了marker的代码,以作示范。

按这个原理,我还测试了标签、多边形、圆形、折线、信息窗口等覆盖物。

运行代码,请点击以下链接:

百度marker:http://ui-love.com/baidumap/apitest/marker-baidu.htm

谷歌marker:http://ui-love.com/baidumap/apitest/marker-google.htm

mapbar:http://ui-love.com/baidumap/apitest/marker-mapbar.htm

mapabc:http://ui-love.com/baidumap/apitest/marker-mapabc.htm

51ditu:http://ui-love.com/baidumap/apitest/marker-51ditu.htm

源代码:

百度marker:

代码

;padding:0;font-family:Times New Roman, serif}
p{margin:0;padding:0}
#wrapper{width:100%;margin:auto;text-align:left;height:100%}
#map_container{height:480px;margin:0}
#notes{position:absolute;right:10px;width:200px;top:10px}

@media print{
input{display:none}
#notes{display:none}
#map_container{margin:10px;border:none}
}
/*]]>*/);

// 内存性能测试
var count = 0;

function createInfo() {
mp.clearOverlays();
if (count > 5000) {
clearInterval(window._timer);
alert("测试结束,一共运行"+count+"次。");
}
createMarkers();
}
function createMarkers(){
var bounds = mp.getBounds();
var lngSpan = bounds.maxX - bounds.minX;
var latSpan = bounds.maxY - bounds.minY;
for (var i = 0; i < 30; i ++) {
count ++;
var point = new BMap.Point(bounds.minX + lngSpan * (Math.random() * 0.7 + 0.15),
bounds.minY + latSpan * (Math.random() * 0.7 + 0.15));
var marker = new BMap.Marker(point);
mp.addOverlay(marker);
}
}
function test_mem() {
window._timer = setInterval(createInfo, 10);
}
function stop_mem() {
clearInterval(window._timer);
alert("运行了"+count+"次");
}
</script>
</html>

谷歌marker:

代码

;padding:0;font-family:Times New Roman, serif}
p{margin:0;padding:0}
#wrapper{width:100%;margin:auto;text-align:left;height:100%}
#map_container{height:480px;margin:0}
#notes{position:absolute;right:10px;width:200px;top:10px}

@media print{
input{display:none}
#notes{display:none}
#map_container{margin:10px;border:none}
}
/*]]>*/);
// 内存性能测试
var count = 0;
function createInfo() {
map.clearOverlays();
if (count > 5000) {
clearInterval(window._timer);
alert("测试结束"+count);
}
createMarkers();
}
function createMarkers(){
// 随机向地图添加 30 个标记
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
for (var i = 0; i < 30; i++) {
count ++;
var latlng = new GLatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(new GMarker(latlng));
}
}
function test_mem() {
window._timer = setInterval(createInfo, 10);
}
function stop_mem() {
clearInterval(window._timer);
alert("计数器"+count);
}
</script>
</html>

mapbar:

代码

;padding:0;font-family:Times New Roman, serif}
p{margin:0;padding:0}
#wrapper{width:100%;margin:auto;text-align:left;height:100%}
#map_container{height:480px;margin:0}
#notes{position:absolute;right:10px;width:200px;top:10px}

@media print{
input{display:none}
#notes{display:none}
#map_container{margin:10px;border:none}
}
/*]]>*/);
maplet.addControl(new MStandardControl());

// 内存性能测试
var count = 0;

function createInfo() {
maplet.clearOverlays();
if (count > 3000) {
clearInterval(window._timer);
alert("测试结束"+count);
}
createMarkers();
}
function createMarkers(){
var lngSpan = 116.43683 - 116.29069;
var latSpan = 39.98916 - 39.88337;
for (var i = 0; i < 30; i ++) {
count ++;
var point = new MPoint(116.29069 + lngSpan * (Math.random() * 0.7 + 0.15),
39.88337 + latSpan * (Math.random() * 0.7 + 0.15));

var marker = new MMarker(
point,
new MIcon("http://union.mapbar.com/apidoc/images/tb1.gif",32,32)
);
maplet.addOverlay(marker);

}
}
function test_mem() {
window._timer = setInterval(createInfo, 10);
}
function stop_mem() {
clearInterval(window._timer);
alert("计数器"+count);
}
</script>
</html>

mapabc:

代码

;padding:0;font-family:Times New Roman, serif}
p{margin:0;padding:0}
#wrapper{width:100%;margin:auto;text-align:left;height:100%}
#map_container{height:480px;margin:0}
#notes{position:absolute;right:10px;width:200px;top:10px}

@media print{
input{display:none}
#notes{display:none}
#map_container{margin:10px;border:none;width:600px; height:500px;overflow:hidden;}
/*]]>*/;//要加载的地图的缩放级别
mapOptions.center=new MLngLat(116.36890411376953,39.913423004886866);//要加载的地图的中心点经纬度坐标
mapOptions.toolbar = DEFAULT;//设置地图初始化工具条
mapObj=new MMap("map_container",mapOptions); //地图初始化

// 内存性能测试
var count = 0;

function createInfo() {
mapObj.removeAllOverlays();
if (count > 5000) {
clearInterval(window._timer);
alert("测试结束");
}
createMarkers();
}
function createMarkers(){
var bounds = mapObj.getLngLatBounds();
myX = bounds.northEast.lngX - bounds.southWest.lngX;
myY = bounds.northEast.latY - bounds.southWest.latY;
for (var i = 0; i < 30; i ++) {
count ++;
var a = bounds.southWest.lngX + myX * (Math.random() * 0.7 + 0.15);
var b = bounds.southWest.latY + myY * (Math.random() * 0.7 + 0.15);
var markerOption = new MMarkerOptions();
markerOption.imageUrl="http://code.mapabc.com/images/lan_1.png";
Mmarker = new MMarker(new MLngLat(a,b),markerOption);
mapObj.addOverlay(Mmarker,true);
}
}
function test_mem() {
window._timer = setInterval(createInfo, 10);
}
function stop_mem() {
clearInterval(window._timer);
alert("计数器"+count);
}
</script>
</html>

51ditu:

代码

";
google_ad_width = 728;
google_ad_height = 90;
//-->
);

// 内存性能测试
var count = 0;

function createInfo() {
mp.clearOverLays();
if (count > 5000) {
clearInterval(window._timer);
alert("测试结束,一共运行"+count+"次。");
}
createMarkers();
}
function createMarkers(){
var bounds = new LTBounds(11630969 , 3979945,11650969 , 3999945);
var lngSpan = bounds.Xmax - bounds.Xmin;
var latSpan = bounds.Ymax - bounds.Ymin;
for (var i = 0; i < 30; i ++) {
count ++;
var point = new LTPoint(bounds.Xmin + lngSpan * (Math.random() * 0.7 + 0.15),
bounds.Ymin + latSpan * (Math.random() * 0.7 + 0.15));
var marker = new LTMarker(point);
mp.addOverLay(marker);
}
}
function test_mem() {
window._timer = setInterval(createInfo, 10);
}
function stop_mem() {
clearInterval(window._timer);
alert("目前运行了"+count+"次");
}
</script>
</html>

附图:

双林寺大雄宝殿一角,对比过多家寺庙,才能发现双林寺的与众不同。当之无愧的“世界文化遗产”!

【百度地图API】多家地图API内存消耗对比测验(带源码)的更多相关文章

  1. Linux简易APR内存池学习笔记(带源码和实例)

    先给个内存池的实现代码,里面带有个应用小例子和画的流程图,方便了解运行原理,代码 GCC 编译可用.可以自己上网下APR源码,参考代码下载链接: http://pan.baidu.com/s/1hq6 ...

  2. Asp.Net Web Api 2 实现多文件打包并下载文件示例源码_转

    一篇关于Asp.Net Web Api下载文件的文章,之前我也写过类似的文章,请见:<ASP.NET(C#) Web Api通过文件流下载文件到本地实例>本文以这篇文章的基础,提供了Byt ...

  3. arcgis api 3.x for js 入门开发系列六地图分屏对比(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...

  4. arcgis api 4.x for js 结合 Echarts4 实现统计图(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 4.x for js:esri 官网 api,里面详细的介绍 arcgis api 4.x 各个类 ...

  5. 没有内涵段子可以刷了,利用Python爬取段友之家贴吧图片和小视频(含源码)

    由于最新的视频整顿风波,内涵段子APP被迫关闭,广大段友无家可归,但是最近发现了一个"段友"的app,版本更新也挺快,正在号召广大段友回家,如下图,有兴趣的可以下载看看(ps:我不 ...

  6. Intel X86 32位CPU内存管理----《Linux内核源码情景分析》笔记(一)

    Intel X86 32位CPU内存管理 在X86系列中,8086和8088是16为处理器,而从80386开始为32为处理器,80286则是该系列从8088到80386,也就是16位处理器到32位处理 ...

  7. mysqld 与 python 邮件监控脚本 内存消耗对比

    top - 21:38:40 up 1 day, 10:38, 5 users, load average: 0.00, 0.01, 0.17Tasks: 88 total, 1 running, 8 ...

  8. 【百度地图API】今日小年大进步,齐头共进贺佳节——API优化升级上线,不再增加内存消耗

    原文:[百度地图API]今日小年大进步,齐头共进贺佳节--API优化升级上线,不再增加内存消耗 任务描述: 今天是2011年01月26日,小年夜.百度地图API在小年夜献给广大API爱好者一份给力的礼 ...

  9. arcgis api 3.x for js 地图加载多个 SHP 图层压缩以及 json 文件展示(附源码下载)

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...

随机推荐

  1. 【Android】android图片轮播

    第一步,先写一个布局文件 <com.main.util.SlideShowView android:id="@+id/slideshowView" android:layou ...

  2. iOS 在下面 AOP 程序

    iOS 在下面 AOP 程序 概念 在软件业.AOP对于Aspect Oriented Programming缩写,手段:面向方面的编程.它是一种函数式编程张燕生风扇类型.通过这样一个技术方案功能的预 ...

  3. [Android 4.4.4] 泛泰A870 通过刷第三版 Mokee4.4.4 KTU84P 20140626 RC2.1 by syhost

    主题及注意事项请访问以前的版本: http://blog.csdn.net/syhost/article/details/29931291 此RC2.1版比RC2.0改进的地方: 1. Mokee本身 ...

  4. Oracle Net Listener Parameters (listener.ora)(转)

    12/20 7 Oracle Net Listener Parameters (listener.ora) This chapter provides a complete listing of th ...

  5. bnu 34982 Beautiful Garden(暴力)

    题目链接:bnu 34982 Beautiful Garden 题目大意:给定一个长度为n的序列,问说最少移动多少点,使得序列成等差序列,点的位置能够为小数. 解题思路:算是纯暴力吧.枚举等差的起始和 ...

  6. Cocos2d-x3.0游戏实例《不要救我》第十篇(结束)——使用Json配置数据类型的怪物

    如今我们有2种类型的怪物,并且创建的时候是写死在代码里的,这是要作死的节奏~ 所以.必须可配置.不然会累死人的. ; i < size; ++i) { int id = root[i][&quo ...

  7. hdu3037Saving Beans

    Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission ...

  8. netback于kthread遇到cpu affinity问题

    最近的升级netback, 在测试过程中,查找vm全双工压力,rx的pps波动很厉害,见rx kthread尽管cpu affinity它是0-7 (dom0 8vcpu), 但往往,她去了物理破坏c ...

  9. cocos2dx --- button点击放大中心

    自定义简单button,直接附着到代码: MenuItem* MenuItemNode::create( const char* normal,Ref* target,SEL_MenuHandler ...

  10. DP Leetcode - Maximum Product Subarray

    近期一直忙着写paper,非常久没做题,一下子把题目搞复杂了..思路理清楚了非常easy,每次仅仅需更新2个值:当前子序列最大乘积和当前子序列的最小乘积.最大乘积被更新有三种可能:当前A[i]> ...