前阵子处理建筑物层重复数据是碰到不同开发语言执行ao程序的效率问题,开始是用vba些的程序,主要是判断完全重复的对象,大概有120万个多边形,执行效率很低,没有执行完就停了;然后用vb写dll执行,效率依然很低,18000个对象的数据,大约要执行2分40秒(cpu:1.5G).后来想到是否用vc写会极大的提高效率呢,折腾了一下午,程序写出来测试的结果让人很失望,几乎没有任何提高。
很是纳闷,也在论坛上问了,没人回答,最后还是在ao的帮助文档中找到了答案:
The performance issues of choosing the development language are not as significant as you might think. Since the majority of the work will be performed within the ArcObjects objects, which are all written in C++, the developer's customization language is for the most part used to control the program flow and user interface interaction. Since Visual Basic uses the same optimized back-end compiler technology that Visual C++ uses, the generated machine code performs at a comparable level. Tests have shown that to perform typical actions on features contained within a database (drawing, querying, editing, and so on), Visual Basic is approximately 2% slower than optimized Visual C++ code, and Visual Basic for Applications is 2% slower than Visual Basic.
也就是说,用ao的com编程,vba、vb和vc效率等级相差2%,所以这么看,从易用性和资源丰富上看,vb是不二之选。
但问题总要解决啊,怎么办,ESRI的另一个产品MapObjects,有合适的空间查询关系支持,用vb编写程序,18000个对象完成一次搜索和删除6秒(CPU:3.0G),其效率比autocad中用vc写arx组建还高近1倍。
应该说mo是esri公司的经典产品,其不再升级和支持vista是令人遗憾的,而ao越来越臃肿,常用功能的优化也不好,比如加载一幅80M的影像,ao控件运行的程序大概要90M物理内存,而mo控件程序只要23M,后者的刷新速度也快得多,ao如果不在web上多下功夫,那这个产品就没什么可圈可点之处了,好在他有了arcgis server这个东西,发散发展的方向似乎在收缩统一了。
离题了,点题:用ao的com编程,vba、vb和vc效率等级相差2%。