原文:【百度地图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. uva133 The Dole Queue ( 约瑟夫环的模拟)

    题目链接: 啊哈哈,选我选我 思路是: 相当于模拟约瑟夫环,仅仅只是是从顺逆时针同一时候进行的,然后就是顺逆时针走能够编写一个函数,仅仅只是是走的方向的标志变量相反..还有就是为了(pos+flag+ ...

  2. LeetCode :: Validate Binary Search Tree[具体分析]

    Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less th ...

  3. C++中的class (2)

    class Father { protected void methodA(){ //do something } private void methodB(){//do something } } ...

  4. RFC 协议下载方法

    rfc官方网站:http://tools.ietf.org 举例说明: RFC7230是HTTP 1.1协议,此文档的URL为:http://tools.ietf.org/html/rfc7230 你 ...

  5. Windows Phone 8 应用内截图

    WriteableBitmap wb = new WriteableBitmap(this.LayoutRoot, new MatrixTransform()); //wb.Render(this.L ...

  6. NOI第一天感想&小结

    嘛...中午总算是到了深圳了--在虹桥机场和飞机上和市队大神们一起讨论各种各样奇(sang)葩(bing)的算(ren)法(lei)还是非常开心的,在此再各种膜拜一下尽管没来比赛的FFT大神@陈中瑞 ...

  7. hdu4570Multi-bit Trie (间隙DP)

    Problem Description IP lookup is one of the key functions of routers for packets forwarding and clas ...

  8. BZOJ 1009 HNOI2008 GT考试 KMP算法+矩阵乘法

    标题效果:给定的长度m数字字符串s.求不包括子s长度n数字串的数目 n<=10^9 看这个O(n)它与 我们不认为这 令f[i][j]长度i号码的最后的字符串j位和s前者j数字匹配方案 例如,当 ...

  9. java类和对象之间的差

    java类和对象之间的差别是一个普遍的问题,刚开始学习java当它来到与类和对象接触.今天就来总结一下它们之间的差异. 先说说class和object差异.事实上,词:object是全部class的父 ...

  10. eclipse 中 Android sdk 无法更新的问题

    诶,真是麻烦,想下个东西都下不了. 我也好久没折腾过这个了,在家的电脑是早就下载好了的,然后如今又须要下载一份.下不到.网上搜到了资料,记录下来: 第一种方法:       sdk manager - ...