SST 12.1.0
Structural Simulation Toolkit
profile.h
1// Copyright 2009-2022 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2022, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_CORE_PROFILE_H
13#define SST_CORE_CORE_PROFILE_H
14
15#include "sst/core/warnmacros.h"
16
17#include <chrono>
18
19namespace SST {
20namespace Core {
21namespace Profile {
22
23#ifdef __SST_ENABLE_PROFILE__
24
25#if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
26#define CLOCK std::chrono::system_clock
27#else
28#define CLOCK std::chrono::steady_clock
29#endif
30
31typedef CLOCK::time_point ProfData_t;
32
33inline ProfData_t
34now()
35{
36 return CLOCK::now();
37}
38
39inline double
40getElapsed(const ProfData_t& begin, const ProfData_t& end)
41{
42 std::chrono::duration<double> elapsed = (end - begin);
43 return elapsed.count();
44}
45
46inline double
47getElapsed(const ProfData_t& since)
48{
49 return getElapsed(since, now());
50}
51
52#else
53typedef double ProfData_t;
54
55inline ProfData_t
56now()
57{
58 return 0.0;
59}
60
61inline double
62getElapsed(const ProfData_t& UNUSED(begin), const ProfData_t& UNUSED(end))
63{
64 return 0.0;
65}
66
67inline double
68getElapsed(const ProfData_t& UNUSED(since))
69{
70 return 0.0;
71}
72
73#endif
74
75} // namespace Profile
76} // namespace Core
77} // namespace SST
78
79#endif // SST_CORE_CORE_PROFILE_H