Re: [Cppcms-users] About raw filter translation.
Brought to you by:
artyom-beilis
From: redred77 <red...@gm...> - 2015-07-05 04:32:09
|
I think you over trusted compiler's inline function. They do their best, but they can't skip making temporary objects. 1. So, I benchmarked. Printed 1000000 times for each and measured with Windows QueryPerformanceCounter(). Of course compiled for Release build. (Full Optimization) out() << "/testtext"; out() << cppcms::filters::raw("/testtext"); Result : 0.109707 sec 0.120335 sec So filters::raw() is actually slower about 9%. 2. You'll be surprised when you see the disassembly. out() << "/testtext"; 00FDC828 mov ecx,ebx 00FDC82A call edi 00FDC82C mov edx,1026F50h 00FDC831 mov ecx,eax 00FDC833 call std::operator<<<std::char_traits<char> > (0FD1A30h) out() << cppcms::filters::raw("/testtext"); 00FDC838 push 1026F50h 00FDC83D lea ecx,[esp+50h] 00FDC841 call dword ptr ds:[10131D8h] 00FDC847 lea eax,[esp+4Ch] 00FDC84B mov dword ptr [esp+0D0h],2 00FDC856 push eax 00FDC857 lea ecx,[esp+2Ch] 00FDC85B call dword ptr ds:[10131CCh] 00FDC861 mov esi,eax 00FDC863 mov ecx,ebx 00FDC865 mov byte ptr [esp+0D0h],3 00FDC86D call edi 00FDC86F push eax 00FDC870 mov ecx,esi 00FDC872 call dword ptr ds:[10131D4h] 00FDC878 lea ecx,[esp+28h] 00FDC87C mov byte ptr [esp+0D0h],2 00FDC884 call dword ptr ds:[10131D0h] 00FDC88A lea ecx,[esp+4Ch] 00FDC88E mov dword ptr [esp+0D0h],0FFFFFFFFh 00FDC899 call dword ptr ds:[10131E0h] There's so many call instructions that are actually not necessary at all. It's because wrapping with filters::raw is not just call and return but it makes and destroy temporary streamable object each time. Here are brief call order. You can also follow this codes one by one with your debugger. streamable::streamable(char const *ptr) streamable::streamable(streamable const &other) raw::raw(streamable const &obj) : obj_(obj) {} inline std::ostream &operator<<(std::ostream &out,raw const &obj) void raw::operator()(std::ostream &out) const void streamable::operator()(std::ostream &out) const void ch_to_stream(std::ostream &out,void const *p) 3. What I like and decided to move to CppCMS the most is that it takes performance seriously. Maybe I'm too concerned about performance, but this is what I learned from the server running currently. It crashed down so many times when visitors explode. Thanks. 2015-07-05 5:06 GMT+09:00 Joerg Sonnenberger <jo...@br...>: > On Sun, Jul 05, 2015 at 02:09:16AM +0900, redred77 wrote: > > It seems like raw filter in view template does nothing but just wraps > input > > variable. > > So below two lines are just same. > > > > out()<<cppcms::filters::raw(content.hello); > > out()<<content.hello; > > > > First one looks more structured which seems like to follow rules like > other > > filters. > > But isn't it better for cppcms_tmpl_cc.py to translate like the second > one > > in a performance aspect view? > > It's inlined. > > Joerg > > > ------------------------------------------------------------------------------ > Don't Limit Your Business. Reach for the Cloud. > GigeNET's Cloud Solutions provide you with the tools and support that > you need to offload your IT needs and focus on growing your business. > Configured For All Businesses. Start Your Cloud Today. > https://www.gigenetcloud.com/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |