diff --git a/src/tracer.cpp b/src/tracer.cpp index 3323b2bb7f3..6eff2de8619 100644 --- a/src/tracer.cpp +++ b/src/tracer.cpp @@ -31,7 +31,7 @@ ttracer::tprint::~tprint() return; } - std::cerr << "Run statistics:\n" + std::cerr << "Run statistics for " << tracer->function << ":\n" << "Runs:\t" << std::dec << tracer->run << "\n"; typedef std::pair, int> thack; @@ -58,8 +58,9 @@ ttracer::tprint::~tprint() std::cerr.setf(original_flag, std::ios_base::adjustfield); } -ttracer::ttracer() +ttracer::ttracer(const char* const function__) : run(0) + , function(function__) , counters() { } diff --git a/src/tracer.hpp b/src/tracer.hpp index f755db70088..5e2d1f51747 100644 --- a/src/tracer.hpp +++ b/src/tracer.hpp @@ -49,11 +49,14 @@ struct ttracer const ttracer* const tracer; }; - ttracer(); + explicit ttracer(const char* const function__); /** The total number of runs. */ int run; + /** The function being traced. */ + const char* const function; + /** * The tracer counters. * @@ -77,9 +80,15 @@ struct ttracer * * @param interval The interval between printing the statistics. */ -#define TRACER_ENTRY(interval) \ - static ttracer tracer; \ +#ifdef __GNUC__ +#define TRACER_ENTRY(interval) \ + static ttracer tracer(__PRETTY_FUNCTION__); \ ttracer::tprint print((++tracer.run % interval) == 0 ? &tracer : NULL) +#else +#define TRACER_ENTRY(interval) \ + static ttracer tracer(__FUNCTION__); \ + ttracer::tprint print((++tracer.run % interval) == 0 ? &tracer : NULL) +#endif /** * A trace count point. @@ -88,7 +97,7 @@ struct ttracer * * @param marker A string with the name of the marker. */ -#define TRACER_COUNT(marker) \ +#define TRACER_COUNT(marker) \ do { \ ++tracer.counters[std::make_pair(__LINE__, marker)]; \ } while(0)