效率指两方面:
1 执行速度的快慢
2 生成可执行文件的大小
我在一个示例程序中对静态事件和动态事件两种方式生成的文件大小进行对比时发现:使用静态事件生成565KB,而动态事件生成566KB。看起来不相上下。
有研究过这方面的吗,给大伙说说或给一下这方面的参考信息。谢谢!
另,大家都喜欢什么样的事件映射方式呢?
请教动态事件与静态事件的效率? Topic is solved
请教动态事件与静态事件的效率?
Life is not fair, get used to it.
可以参看event.h和event.cpp。
Event Table 用array,用for-loop找对应的function:
Connect 则用wxList,也是一个个找对应的function:
效率应该是差不多的,各种平台、编译器也可能有分别。
两者的分别,是Event Table可读性较好;而Connect则较灵活(),请参考wxBlog:
http://wxwidgets.blogspot.com/2007/01/i ... nnect.html
Event Table 用array,用for-loop找对应的function:
Code: Select all
for (size_t n = 0; n < count; n++)
{
if ( wxEvtHandler::
ProcessEventIfMatches(*eventEntryTable[n], self, event) )
{
return true;
}
}
Code: Select all
node = node->GetNext();
if ((event.GetEventType() == entry->m_eventType) && (entry->m_fn != 0))
{
wxEvtHandler *handler =
#if !WXWIN_COMPATIBILITY_EVENT_TYPES
entry->m_eventSink ? entry->m_eventSink
:
#endif
this;
if ( ProcessEventIfMatches(*entry, handler, event) )
{
return true;
}
两者的分别,是Event Table可读性较好;而Connect则较灵活(),请参考wxBlog:
http://wxwidgets.blogspot.com/2007/01/i ... nnect.html
楼上讲得精辟~学习了~
个人强烈偏好动态事件,也多次用它取消或改变事件的关联,对它爱不释手。
-Utensil
个人强烈偏好动态事件,也多次用它取消或改变事件的关联,对它爱不释手。
-Utensil
In fascination of creating worlds by words, and in pursuit of words behind the world.
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/
On Github: http://utensil.github.com
Technical Blog in Chinese: http://utensil.iteye.com/