SST  6.1.0
StructuralSimulationToolkit
profile.h
1 // Copyright 2009-2016 Sandia Corporation. Under the terms
2 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2014, Sandia Corporation
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 <chrono>
16 
17 namespace SST {
18 namespace Core {
19 namespace Profile {
20 
21 
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 
31 
32 typedef CLOCK::time_point ProfData_t;
33 
34 inline ProfData_t now()
35 {
36  return CLOCK::now();
37 }
38 
39 inline double getElapsed(const ProfData_t &begin, const ProfData_t &end)
40 {
41  std::chrono::duration<double> elapsed = (end - begin);
42  return elapsed.count();
43 }
44 
45 
46 inline double getElapsed(const ProfData_t &since)
47 {
48  return getElapsed(since, now());
49 }
50 
51 
52 #else
53 typedef double ProfData_t;
54 
55 inline ProfData_t now()
56 {
57  return 0.0;
58 }
59 
60 inline double getElapsed(const ProfData_t &begin, const ProfData_t &end)
61 {
62  return 0.0;
63 }
64 
65 
66 inline double getElapsed(const ProfData_t &since)
67 {
68  return 0.0;
69 }
70 
71 
72 
73 #endif
74 
75 
76 
77 }
78 }
79 }
80 
81 #endif
Definition: action.cc:17