FAlgorithmTimers.hpp 2.34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// ===================================================================================
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Berenger Bramas
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// 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 and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================

#ifndef FALGORITHMTIMERS_HPP
#define FALGORITHMTIMERS_HPP

20
21
22
23
24
#include <map>
#include <string>

#include "FTic.hpp"

25
/**
26
 * @brief Collection of timers for FMM operators.
27
 *
28
29
 * This class provide a way for the different algorithms to
 * store the time spent in each operator.
30
31
32
 */
class FAlgorithmTimers{
public:
33
34
35
36
37
38
39
40
41
42
    static constexpr const char* P2MTimer = "P2M";
    static constexpr const char* M2MTimer = "M2M";
    static constexpr const char* M2LTimer = "M2L";
    static constexpr const char* L2LTimer = "L2L";
    static constexpr const char* L2PTimer = "L2P";
    static constexpr const char* P2PTimer = "P2P";
    static constexpr const char* M2PTimer = "M2P";
    static constexpr const char* P2LTimer = "P2L";
    static constexpr const char* NearTimer = "Near";
    enum {nbTimers = 9};
43

44
45
    /// Timers
    std::map<std::string, FTic> Timers;
46

47
    /// Constructor: resets all timers
48
    FAlgorithmTimers() = default;
49

50
51
52
53
    /// Default copy contructor
    FAlgorithmTimers(const FAlgorithmTimers&) = default;
    /// Default move contructor
    FAlgorithmTimers(FAlgorithmTimers&&) = default;
54

55
    /// Elapsed time between last FTic::tic() and FTic::tac() for given timer.
56
    double getTime(std::string TimerName) const{
57
        //assert to verify size
58
        return Timers.at(TimerName).elapsed();
59
60
    }

61
    /// Cumulated time between all FTic::tic() and FTic::tac() for given timer.
62
    double getCumulatedTime(std::string TimerName) const{
63
        //assert to verify size
64
        return Timers.at(TimerName).cumulated();
65
66
67
68
69
    }

};

#endif // FALGORITHMTIMERS_HPP