The Battle for Wesnoth  1.15.2+dev
Classes | Macros
tracer.hpp File Reference

Contains code for tracing the code. More...

#include <map>
#include <string>
Include dependency graph for tracer.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tracer
 Helper structure for gathering the tracing statistics. More...
 
struct  tracer::printer
 Helper structure to print the tracing statistics. More...
 

Macros

#define TRACER_ENTRY(interval)
 The beginning of a traced scope. More...
 
#define TRACER_COUNT(marker)
 A trace count point. More...
 

Detailed Description

Contains code for tracing the code.

Definition in file tracer.hpp.

Macro Definition Documentation

◆ TRACER_COUNT

#define TRACER_COUNT (   marker)
Value:
do { \
++tracer.counters[std::make_pair(__LINE__, marker)]; \
} while(0)
Helper structure for gathering the tracing statistics.
Definition: tracer.hpp:26
std::map< std::pair< int, std::string >, int > counters
The tracer counters.
Definition: tracer.hpp:72

A trace count point.

When this macro is reached the counter for this marker is increased.

Parameters
markerA string with the name of the marker.

Definition at line 100 of file tracer.hpp.

◆ TRACER_ENTRY

#define TRACER_ENTRY (   interval)
Value:
static struct tracer tracer(__FUNCTION__); \
tracer::printer print((++tracer.run % interval) == 0 ? &tracer : nullptr)
static void print(std::stringstream &sstr, const std::string &queue, const std::string &id)
Definition: fire_event.cpp:29
int run
The total number of runs.
Definition: tracer.hpp:55
Helper structure for gathering the tracing statistics.
Definition: tracer.hpp:26

The beginning of a traced scope.

It is not intended that tracer scopes are nested, but it should work at the moment.

Parameters
intervalThe interval between printing the statistics.

Definition at line 88 of file tracer.hpp.