In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
In AIX, the xlc compiler has an option-qfunctrace, and programs compiled with this option automatically call the following custom function at the entrance and exit of each function.
Extern "C" void
_ _ func_trace_enter (const char * const proc_name
Const char * const file_name
Const int line_no
Void * * const id)
Extern "C" void
_ _ func_trace_exit (const char * const proc_name
Const char * const file_name
Const int line_no
Void * * const id)
Extern "C" void
_ _ func_trace_catch (const char * const proc_name
Const char * const file_name
Const int line_no
Void * * const id)
Execute _ _ func_trace_enter () before the function call, and _ _ func_trace_exit () after the function returns normally. If the function is thrown through a throw exception, execute _ _ func_trace_catch () where the exception is caught by catch, but encounter catch (...). The capture will not be performed. It is worth noting that if throw is thrown, _ _ func_trace_exit () will not be triggered.
Using this function, you can achieve the effect of performance statistics without modifying the source program. The procedure is as follows.
Tr.cpp is a custom function entry and exit program, which passes through each function when it is executed. Compiled into libfunctr.so.
# include
# include
# include
# include
Using std::vector
Using std::string
Using std::clog
Using std::endl
Extern "C" void print_trace ()
Struct Stat
{
Int lvl
String name
Long stm
Long etm
Long oitv
Stat (int l, const string& s, long st): lvl (l), name (s), stm (st), etm (0), oitv (0) {}
}
Static vector tracev
Static int clvl = 0
Extern "C" void
_ _ func_trace_enter (const char * const proc_name
Const char * const file_name
Const int line_no
Void * * const id)
{
/ / printf ("{% s (% s% d)% p% s\ n", proc_name, file_name, line_no, id [0], (char*) * id)
Struct timeval nowtm
Gettimeofday (& nowtm, NULL)
+ + clvl
Tracev.push_back (Stat (clvl, string (proc_name) + "():" + file_name, nowtm.tv_sec * 1000000 + nowtm.tv_usec))
}
Extern "C" void
_ _ func_trace_exit (const char * const proc_name
Const char * const file_name
Const int line_no
Void * * const id)
{
/ / printf ("}% s (% SVA% d)% p% s\ n", proc_name, file_name, line_no, id [0], (char*) * id)
Struct timeval nowtm
Int itv
Gettimeofday (& nowtm, NULL)
Auto iter = tracev.end ()-1
While (iter- > etm! = 0)
-- iter
Iter- > etm = nowtm.tv_sec * 1000000 + nowtm.tv_usec
Itv = iter- > etm-iter- > stm-iter- > oitv
For (auto s = tracev.begin (); swords tracev.end (); slots +)
{
If (s-> etm = = 0)
S-> oitv + = itv
}
-- clvl
If (clvl = = 0)
Print_trace ()
}
Extern "C" void print_trace ()
{
Time_t t
Char buf [30]
For (auto s = tracev.begin (); swords tracev.end (); slots +)
{
Clog
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.