boost::logging::profile Namespace Reference

Allows profiling your application. More...


Classes

struct  compute
 Computes profiling information, and can show it to the user. More...
struct  compute_filter
 Profiles a filter. Don't use directly, use compute_for_filter instead. More...
struct  logger_to_write
 given the logger type, gets the write_msg part, without needing to know the logger's definition (a typedef is enough) More...
struct  compute_for_logger
 Allows you to compute profiling for your logger class. More...
struct  compute_for_filter
 Allows you to compute profiling for your filter class. More...


Detailed Description

Allows profiling your application.

If you want to profile your application (find out how much time is spent logging), all you need to do is to surround your logger and filter class(es) by profile::compute_for_logger and with profile::compute_for_filter, like shown below:

Your code:

namespace bl = boost::logging;
typedef bl::logger_format_write< > logger_type;
typedef bl::filter::no_ts filter_type;

Your code with profiling:

// notice the extra include
#include <boost/logging/profile.hpp>

namespace bl = boost::logging;
typedef bl::logger_format_write< > raw_logger_type;
typedef bl::profile::compute_for_logger<raw_logger_type>::type logger_type;
typedef bl::filter::no_ts raw_filter_type;
typedef bl::profile::compute_for_filter<raw_filter_type>::type filter_type;

In addition to the above, you'll need to set a place where to dump the profile information (which will be dumped at end of the program). This is just a functor that takes a const std::string& argument. Thus, it can be any destination class. For instance:

// where shall the profile results be outputted?
bl::profile::compute::inst().log_results( bl::destination::file("profile.txt") );


Results can look like this:

gather time:      5.562500 seconds 
write time:       5.265625 seconds 
filter time:      0.31250 seconds 
otherthread time: 0.0 seconds 



For more info, see compute_for_logger and compute_for_filter classes.



Copyright John Torjo © 2007
Have a question/ suggestion/ comment? Send me feedback