c++ - Is it a good thing that the top items in my programs profile are _Unwind_SjLj_Unregister and _Unwind_SjLj_Register? -
as follow this question, thing top 2 things still exception handlers? on 1 hand, doing lot of exceptions. on other, in sdl, meaning optimized possible, means other functions fast. so...
here's top of profile of program after running around 64 seconds, after did optimization
flat profile: each sample counts 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 8.32 3.39 3.39 _unwind_sjlj_register 6.77 6.15 2.76 _unwind_sjlj_unregister 6.28 8.71 2.56 4000006 0.00 0.00 cast128::setkey(std::string) 3.73 10.23 1.52 std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() 3.61 11.70 1.47 __dynamic_cast 3.56 13.15 1.45 64000080 0.00 0.00 cast128::f(int&, unsigned int&, unsigned int&, unsigned char&) 3.26 14.48 1.33 std::string::_rep::_s_create(unsigned int, unsigned int, std::allocator<char> const&) 3.09 15.74 1.26 std::istreambuf_iterator<char, std::char_traits<char> > std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > >::_m_extract_int<unsigned long long>(std::istreambuf_iterator<char, std::char_traits<char> >, std::istreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, std::_ios_iostate&, unsigned long long&) const 2.94 16.94 1.20 std::string::compare(char const*) const 2.32 17.89 0.94 4002455 0.00 0.00 unhexlify(std::string) 2.06 18.73 0.84 std::string::operator[](unsigned int) 2.01 19.55 0.82 32037245 0.00 0.00 std::string makehex<int>(int, unsigned int) 1.94 20.34 0.79 std::string::_rep::_m_clone(std::allocator<char> const&, unsigned int) 1.91 21.11 0.78 operator new(unsigned int) 1.87 21.88 0.76 std::string::append(std::string const&)
cast128 run 100000 times, explains explains why on top
these not exception handlers, rather functions notify exception handler of destructors need called if exception thrown. example, consider
for (int = 0; < 1000000; ++i) { std::string stuff; // or type non-trivial destructor function(); // maybe arguments depend on "stuff" // inline code using "stuff" here }
every iteration, string created , destroyed, , must registered , unregistered exception handler each time in case function()
throws. may able avoid overhead in various ways, depending on how object used:
- if object (or created it) not passed function, move definition after function call
- declare
function
(and functions calls)inline
, exception thrown same stack frame object; believe won't necessary register object then, long function inlined - make sure
function
won't throw exception, , addthrow()
specification it - move object outside loop, reinitialising (or calling
clear()
in example) if necessary @ start of each iteration (this eliminate overhead of creating , destroying it)
Comments
Post a Comment