UsingomniORBinterceptorstorecordtimecostedinCORBAcalls(转)[@more@]
struct CallInfo
{
std::string opname;
DWORD time;
};
std::map
> calls; static CORBA::Boolean sendReqFunc(omni::omniInterceptors::clientSendRequest_T::info_T& info) { if(!info.response_expected){ CallInfo c; c.opname = info.opname; c.time = ::GetTickCount(); calls[GetCurrentThreadId()].push(c); } return TRUE; } static CORBA::Boolean receiveRepFunc(omni::omniInterceptors::clientReceiveReply_T::info_T& info) { DWORD t = ::GetTickCount(); if(!calls[GetCurrentThreadId()].empty()){ const CallInfo& c = calls[GetCurrentThreadId()].top(); TRACE("==== %s , %d ms ====
", c.opname.c_str(), t - c.time); calls[GetCurrentThreadId()].pop(); } return TRUE; } And here is how to register the inteceptors after the ORB_init call: omni::omniInterceptors* interceptors = omniORB::getInterceptors(); interceptors->clientSendRequest.add(sendReqFunc); interceptors->clientReceiveReply.add(receiveRepFunc)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8225414/viewspace-965580/
,如需转载,请注明出处,否则将追究法律责任。