ATLAS Offline Software
Loading...
Searching...
No Matches
BasicStopWatch.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef PMONUTILS_BASICSTOPWATCH_H
6#define PMONUTILS_BASICSTOPWATCH_H
7
8#include <chrono>
9#include <string>
10
11#include "tbb/concurrent_hash_map.h"
12
13namespace PMonUtils {
14
15 typedef tbb::concurrent_hash_map<std::string, double> BasicStopWatchResultMap_t;
16
18
19 public:
20 // Constructor
21 BasicStopWatch(const std::string& name, BasicStopWatchResultMap_t& result) :
22 m_name(name), m_result(result), m_start(std::chrono::steady_clock::now()) { }
23
24 // Destructor
26 std::chrono::duration<double, std::milli> total = std::chrono::steady_clock::now() - m_start;
27 tbb::concurrent_hash_map<std::string, double>::accessor acc;
28 m_result.insert(acc, m_name);
29 acc->second += total.count();
30 acc.release();
31 }
32
33 private:
34 // Name of the current StopWatch
35 std::string m_name;
36
37 // Reference to the BasicStopWatchResultMap_t
39
40 // Start time of the current StopWatch
41 std::chrono::time_point<std::chrono::steady_clock> m_start;
42
43 }; // end class BasicStopWatch
44
45} // end namespace PMonUtils
46
47#endif
BasicStopWatch(const std::string &name, BasicStopWatchResultMap_t &result)
BasicStopWatchResultMap_t & m_result
std::chrono::time_point< std::chrono::steady_clock > m_start
tbb::concurrent_hash_map< std::string, double > BasicStopWatchResultMap_t
STL namespace.