【百度地图API】多家地图API内存消耗对比测验(带源码)
原文:【百度地图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:


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:


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:


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:


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内存消耗对比测验(带源码)的更多相关文章
- Linux简易APR内存池学习笔记(带源码和实例)
先给个内存池的实现代码,里面带有个应用小例子和画的流程图,方便了解运行原理,代码 GCC 编译可用.可以自己上网下APR源码,参考代码下载链接: http://pan.baidu.com/s/1hq6 ...
- Asp.Net Web Api 2 实现多文件打包并下载文件示例源码_转
一篇关于Asp.Net Web Api下载文件的文章,之前我也写过类似的文章,请见:<ASP.NET(C#) Web Api通过文件流下载文件到本地实例>本文以这篇文章的基础,提供了Byt ...
- arcgis api 3.x for js 入门开发系列六地图分屏对比(附源码下载)
前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...
- arcgis api 4.x for js 结合 Echarts4 实现统计图(附源码下载)
前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 4.x for js:esri 官网 api,里面详细的介绍 arcgis api 4.x 各个类 ...
- 没有内涵段子可以刷了,利用Python爬取段友之家贴吧图片和小视频(含源码)
由于最新的视频整顿风波,内涵段子APP被迫关闭,广大段友无家可归,但是最近发现了一个"段友"的app,版本更新也挺快,正在号召广大段友回家,如下图,有兴趣的可以下载看看(ps:我不 ...
- Intel X86 32位CPU内存管理----《Linux内核源码情景分析》笔记(一)
Intel X86 32位CPU内存管理 在X86系列中,8086和8088是16为处理器,而从80386开始为32为处理器,80286则是该系列从8088到80386,也就是16位处理器到32位处理 ...
- 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 ...
- 【百度地图API】今日小年大进步,齐头共进贺佳节——API优化升级上线,不再增加内存消耗
原文:[百度地图API]今日小年大进步,齐头共进贺佳节--API优化升级上线,不再增加内存消耗 任务描述: 今天是2011年01月26日,小年夜.百度地图API在小年夜献给广大API爱好者一份给力的礼 ...
- arcgis api 3.x for js 地图加载多个 SHP 图层压缩以及 json 文件展示(附源码下载)
前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...
随机推荐
- IT忍者神龟之使用 PowerDesigner
1. 启动 PowerDesigner 新建物理数据模型 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdmlweWhk/font/5a6L5L2T/fon ...
- hdu 2454 Degree Sequence of Graph G (推断简单图)
///已知各点的度,推断是否为一个简单图 #include<stdio.h> #include<algorithm> #include<string.h> usin ...
- 了解HTML5和“她”的 API (二)
Communication(通信) Cross Document Messaging (跨文档消息通信) postMessage API origin security(源安全) chat ...
- SQL server 提示“代理XP”被关闭的解决方法
打开SQL Server Configuration Manager(SQL Server配置管理器),启用SQL Server Agent(SQL Server 代理).
- 非常棒的Visual Studo调试插件:OzCode 2.0 下载地址
最新版下载地址 http://download.csdn.net/detail/simadi/8925511 如果你是一名C#开发者,那么,你则需要OzCode.它将可视化调试的概念上升到了一个新的高 ...
- 《Tips for Optimizing C/C++ Code》译文
前不久在微博上看到一篇非常好的短文讲怎样对C/C++进行性能优化,尽管其面向的领域是图形学中的光线跟踪,可是还是具有普遍的意义,将其翻译成中文,希望对大家写高质量代码有帮助. 1. 牢记阿姆达 ...
- 概率统计(DP)
问题叙述性说明 生成n个月∈[a,b]随机整数.并且将它们输出到x概率. 输入格式 输入线跟四个整数n.a,b,x,用空格分隔. 输出格式 输出一行包括一个小数位和为x的概率.小数点后保留四位小数 例 ...
- 2014.06.14 GlusterFS技术交流视频
6月14线下GlusterFS视频交流.高清视频是非常好的,我初听言论方面,谈到迅速,似乎不是很清楚,讲座结束后速度需要改进.谢谢能力的天空AbleSky高大内设,谢谢学生参加. 在线公开课:http ...
- HDU 3103 Shoring Up the Levees(计算几何 搜寻区域)
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=3103 Problem Description The tiny country of Waterlog ...
- SQL Server 2005------函数
原文:SQL Server 2005------函数 SQL Server 2005支持用户自定义函数和内置系统函数,根据返回值类型又分为标量函数和表值函数. 1.标量函数标量函数:返回单个数据值,返 ...