Timer.h 1.46 KB
Newer Older
frey_m's avatar
frey_m committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
//
// Class Timer
//   This class is used in IpplTimings.
//   https://www.boost.org/doc/libs/1_70_0/libs/timer/doc/cpu_timers.html
//
// Copyright (c) 2019, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// Implemented as part of the PhD thesis
// "Precise Simulations of Multibunches in High Intensity Cyclotrons"
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
gsell's avatar
gsell committed
22 23 24
#ifndef TIMER_H
#define TIMER_H

25
#include <boost/timer/timer.hpp>
gsell's avatar
gsell committed
26 27 28 29

class Timer
{
public:
30 31 32 33 34 35 36 37 38 39 40 41
    
    Timer();
    
    void clear();               // Set all accumulated times to 0
    void start();               // Start timer
    void stop();                // Stop timer
    
    double clock_time();        // Report clock time accumulated in seconds
    double user_time();         // Report user time accumlated in seconds
    double system_time();       // Report system time accumulated in seconds
    double cpu_time();          // Report total cpu_time which is just user_time + system_time
    
gsell's avatar
gsell committed
42
private:
43 44 45 46
    double wall_m;
    double user_m;
    double sys_m;
    boost::timer::cpu_timer timer_m;
gsell's avatar
gsell committed
47 48
};

49
#endif