Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
otb
otb
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 298
    • Issues 298
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 14
    • Merge Requests 14
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Main Repositories
  • otbotb
  • Issues
  • #1972

Closed
Open
Opened Sep 30, 2019 by Luc Hermitte@lhermitteContributor

Improving log macro performances

The way logging macros are defined, they could consume a lot of time if passed slow functions. IOW,

otbMsgDevMacro(somethingslowandcalledforeachpixel());

would yield to inefficient code.

The usual way to fix this would be

#define otbLogMacro(level,msg)                                    \
  if (otb::Logger::Instance()->ShouldWeLog(level))                \  // <-- the new line
  {                                                               \
    std::ostringstream itkmsg;                                    \
    itkmsg msg << "\n";                                           \
    otb::Logger::Instance()->level(itkmsg.str().c_str());         \
  }

BTW, the std::string shall not be converted into a char const* to be converted back into an std::string -> get rid of .c_str().

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: orfeotoolbox/otb#1972