[转帖]Qt和MFC的效率对比_Android, Python及开发编程讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Android, Python及开发编程讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 3666 | 回复: 0   主题: [转帖]Qt和MFC的效率对比        下一篇 
hao.zhang
注册用户
等级:上尉
经验:735
发帖:60
精华:0
注册:2013-10-25
状态:离线
发送短消息息给hao.zhang 加好友    发送短消息息给hao.zhang 发消息
发表于: IP:您无权察看 2013-10-30 16:12:08 | [全部帖] [楼主帖] 楼主

之前一直做mfc,昨天看了一晚上的Qt,瞬间就喜欢上它了,Qt在windows下应该没有mfc的运行效率高,但是我想知道差多少,不知有没有大牛做过这方面的对比。Qt和MFC,WinForm,WPF这几个对比,在哪个位置?

回答:

Qt 是 C++ 的一个框架,要说慢的话,可能信号槽的触发会慢点。但是几乎可以忽略不计。

Qt 的官方文档有大约这么一段话

Compared to callbacks, signals and slots are slightly slower because of the increased flexibility they provide, although the difference for real applications is insignificant. In general, emitting a signal that is connected to some slots, is approximately ten times slower than calling the receivers directly, with non-virtual function calls. This is the overhead required to locate the connection object, to safely iterate over all connections (i.e. checking that subsequent receivers have not been destroyed during the emission), and to marshall any parameters in a generic fashion. While ten non-virtual function calls may sound like a lot, it's much less overhead than any new or delete operation, for example. As soon as you perform a string, vector or list operation that behind the scene requires new or delete, the signals and slots overhead is only responsible for a very small proportion of the complete function call costs.
The same is true whenever you do a system call in a slot; or indirectly call more than ten functions. On an i586-500, you can emit around 2,000,000 signals per second connected to one receiver, or around 1,200,000 per second connected to two receivers. The simplicity and flexibility of the signals and slots mechanism is well worth the overhead, which your users won't even notice.


就是说,信号槽机制比回调机制慢10倍。主要损失在类型检查和参数安全上。
想想也是,人们会关心点击一个按钮后,多长时间完成任务。而很少会关心点击一个按钮后,多快的开始任务。

至于,信号槽机制的性能,大约可以每秒处理2百万个信号。
也就是说,你有 2000个 定时器,每个定时器 每秒触发 1000次。就达到了信号槽机制的瓶颈。我想如果这样的话,MFC也会很累。

至于其他 框架,没有什么可比性,他们是托管代码。




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论