Flow123d  build_with_4.0.3-86a16ad
Classes | Namespaces | Macros
sys_profiler.hh File Reference


More...

#include "global_defs.h"
#include <mpi.h>
#include <ostream>
#include <unordered_map>
#include <boost/functional/hash/hash.hpp>
#include <boost/ref.hpp>
#include <boost/tuple/detail/tuple_basic.hpp>
#include <nlohmann/json.hpp>
#include "time_point.hh"
#include "petscsys.h"
#include "simple_allocator.hh"

Go to the source code of this file.

Classes

class  MPI_Functions
 
class  Profiler
 

Namespaces

 boost
 

Macros

#define CONSTEXPR_   constexpr
 
#define _PASTE(a, b)   a ## b
 
#define PASTE(a, b)   _PASTE(a, b)
 
#define START_TIMER(tag)
 Starts a timer with specified tag. More...
 
#define START_TIMER_EXT(tag, subtag)
 Starts a timer with specified tag and subtag. More...
 
#define END_TIMER(tag)
 Ends a timer with specified tag. More...
 
#define END_START_TIMER(tag)
 
#define ADD_CALLS(n_calls)
 Increase number of calls in actual timer. More...
 
#define CUMUL_TIMER(tag)   0
 

Detailed Description


 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Todo:
  • START_GLOBAL_TIMER(tag) - this calls the start_timer, which creates local timer on the correct place in the hierarchy, further this timer is added to the list of global timers, this contains groups of timers with same tag, and collect/sum data from these timers in the report.

Definition in file sys_profiler.hh.

Macro Definition Documentation

◆ _PASTE

#define _PASTE (   a,
 
)    a ## b

Definition at line 92 of file sys_profiler.hh.

◆ ADD_CALLS

#define ADD_CALLS (   n_calls)

Increase number of calls in actual timer.

Some time you want to measure a performance of a cycle with body that is below resolution of the Timer implementation. If you know number of cycles, you can use this macro in following way:

START_TIMER("cycle");
unsigned int i;
for(i =0; i<1000000; i++) i*i*i;
END_TIMER("cycle");
#define END_TIMER(tag)
Ends a timer with specified tag.
#define ADD_CALLS(n_calls)
Increase number of calls in actual timer.
#define START_TIMER(tag)
Starts a timer with specified tag.

In the profiler report you get the total time spent in the cycle, and time per one call which will be average time spent in the body of the cycle.

Definition at line 186 of file sys_profiler.hh.

◆ CONSTEXPR_

#define CONSTEXPR_   constexpr

Definition at line 86 of file sys_profiler.hh.

◆ CUMUL_TIMER

#define CUMUL_TIMER (   tag)    0

Definition at line 193 of file sys_profiler.hh.

◆ END_START_TIMER

#define END_START_TIMER (   tag)

Ends current timer and starts the new one with given tag. Again this expands into two lines, see ATTENTION in previous macro.

Definition at line 160 of file sys_profiler.hh.

◆ END_TIMER

#define END_TIMER (   tag)

Ends a timer with specified tag.

Use only if you want to end timer before the end of block. Again this expands into two lines, see ATTENTION in previous macro.

Definition at line 149 of file sys_profiler.hh.

◆ PASTE

#define PASTE (   a,
 
)    _PASTE(a, b)

Definition at line 93 of file sys_profiler.hh.

◆ START_TIMER

#define START_TIMER (   tag)

Starts a timer with specified tag.

In fact it creates an static constant expression that identifies the point in the code and contains tag of the involved timer and its hash. Then it creates local variable that calls Profiler::start_timer() in constructor and Profiler::stop_timer() in destructor. This way the timer is automatically closed at the end of current block.

ATTENTION: This macro expands to two statements so following code is illegal:

if (some_condition) START_TIMER(tag);

Definition at line 115 of file sys_profiler.hh.

◆ START_TIMER_EXT

#define START_TIMER_EXT (   tag,
  subtag 
)

Starts a timer with specified tag and subtag.

In fact it creates an static constant expression that identifies the point in the code and contains tag and subtag of the involved timer and its hash. Then it creates local variable that calls Profiler::start_timer() in constructor and Profiler::stop_timer() in destructor. This way the timer is automatically closed at the end of current block.

ATTENTION: This macro expands to two statements so following code is illegal:

if (some_condition) START_TIMER_EXT(tag, subtag);
#define START_TIMER_EXT(tag, subtag)
Starts a timer with specified tag and subtag.

Definition at line 136 of file sys_profiler.hh.