Ignore:
Timestamp:
Mar 18, 2010, 11:33:54 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
6acc8e4
Parents:
f87c2a
git-author:
Frederik Heber <heber@…> (03/18/10 10:26:55)
git-committer:
Frederik Heber <heber@…> (03/18/10 11:33:54)
Message:

Log() and eLog() are prepended by a DoLog()/DoeLog() construct.

  • Most of the run time (95%) is spent on verbosity that it is discarded anyway due to a low verbosity setting. However, the operator << is evaluated from the right-hand side, hence the whole message is constructed and then thrown away.
  • DoLog() and DoeLog() are new functions that check the verbosity beforehand and are used as follows: DoLog(2) && (Log() << verbose(2) << "message" << endl);

Signed-off-by: Frederik Heber <heber@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/log.cpp

    rf87c2a r12f57b  
    2828}
    2929
     30/** Checks verbosity for logger.
     31 * Is supposed to be used in construct as this:
     32 * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
     33 * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
     34 * \param verbose verbosity level of this message
     35 * \return true - print, false - don't
     36 */
     37bool DoLog(int verbose) {
     38  return verbose <= logger::getInstance()->verbosity;
     39}
     40
     41/** Checks verbosity for errorlogger.
     42 * Is supposed to be used in construct as this:
     43 * DoLog(2) && (Log() << Verbose(2) << "message." << endl);
     44 * If DoLog does not return true, the right-hand side is not evaluated and we save some time.
     45 * \param verbose verbosity level of this message
     46 * \return true - print, false - don't
     47 */
     48bool DoeLog(int verbose) {
     49  return verbose <= errorLogger::getInstance()->verbosity;
     50}
     51
    3052/**
    3153 * Prints an error log entry.
Note: See TracChangeset for help on using the changeset viewer.