Hello Gustavo,

On Mon, Mar 10, 2014 at 12:45 PM, Gustavo Sverzut Barbieri
<barbi...@gmail.com> wrote:
> Cedric,
>
> while I agree with performance concerns, nobody is doing core parts in
> C++ (yet), so for the random app user this is negligible performance
> hit. Of course C++ mixes nicely with C, so it is still possible to use
> the original macros/functions which will execute vfprintf() only if
> log level is required.
>
> Felipe, could we make the operator implementations just return if
> current log level is not to be used? Like, in the beginning of the
> operator we could do:
>
>     if (eina_log_domain_registered_level_get(mydom.id) >
> EINA_LOG_LEVEL_DBG) return;  // used for mydom.dbg "io";

One problem is that we can't stop the evaluation of function calls, so
for example:

err << "hello world " << expensive_call();

expensive_call is evaluated before the operator overload runs. By
that time, it doesn't really matter anymore. Also, the check runs
multiple times for each operator<< function call.

Also, with the positive case for logging we must share
std::stringstream's or create one for each operator<< call. Both
have important disadvantages, for the first we need synchronization,
for the second we don't get amortized dynamic allocations. It is
already bad that I can't steal the std::string from std::stringstream,
which means an unnecessary copy.

Since I can't stop evaluation of expressions without macros here,
it can have a significant impact on performance.

> that way the performance impact is negligible. AFAIR the evaluation is
> left->right, thus the following could be grouped as:
>
>     mydom.dbg << "hello world" << 0.3456;
>    (mydom.dbg << "hello world") << 0.3456;
>
> which usually the operator<<() would return an instance of itself,
> then it results in:
>
>    mydom.dbg << "hello world" << 0.3456;
>    mydom.dbg << "hello world";  mydom.dbg << 0.3456;
>
> so if operator<<() does the level check (which is very light), then we
> get performance and usability.

For printing constants that is true, but not negligible for expressions
that are expensive to evaluate.

What I *may* do is: (without impacting performance)

EINA_CXX_DOM_LOG_CRIT(domain) << "hello world " << 0.3456;

But I'm not 100% sure.

Even with expression templates I can't stop the evaluation of the
expressions, because it is its results that are passed to the
operator<< function call as arguments.

[snip]

> --
> Gustavo Sverzut Barbieri
> --------------------------------------
> Mobile: +55 (19) 99225-2202
> Contact: http://www.gustavobarbieri.com.br/contact

Regards,
-- 
Felipe Magno de Almeida

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to