timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::component::timestamp Struct Reference

this component stores the timestamp of when a bundle was started and is specialized such that the "timeline_storage" type-trait is true. This means that every entry in the call-graph for this output will be unique (look in the timestamp.txt output file) More...

#include "timemory/components/timestamp/timestamp.hpp"

+ Collaboration diagram for tim::component::timestamp:

Public Types

using value_type = timestamp_entry_t
 
using base_type = base< timestamp, value_type >
 
using clock_type = std::chrono::system_clock
 
using time_point_type = typename clock_type::time_point
 
using duration_type = std::chrono::duration< clock_type::rep, std::nano >
 
using storage_type = empty_storage
 

Public Member Functions

void sample ()
 
void start ()
 
value_type get () const
 
std::string get_display () const
 
template<typename ArchiveT >
void load (ArchiveT &ar, const unsigned)
 
template<typename ArchiveT >
void save (ArchiveT &ar, const unsigned) const
 
timestampoperator+= (const timestamp &)
 
timestampoperator/= (const timestamp &)
 
timestampoperator/= (int64_t)
 

Static Public Member Functions

static std::string label ()
 
static std::string description ()
 
static value_type record ()
 
static value_type get_reference_ts ()
 
static std::string as_string (const time_point_type &_tp)
 
static int64_t count ()
 
template<typename ArchiveT >
static void extra_serialization (ArchiveT &)
 
template<typename... Args>
static opaque get_opaque (Args &&...)
 

Friends

std::ostream & operator<< (std::ostream &_os, const timestamp &_ts)
 

Detailed Description

this component stores the timestamp of when a bundle was started and is specialized such that the "timeline_storage" type-trait is true. This means that every entry in the call-graph for this output will be unique (look in the timestamp.txt output file)

Definition at line 49 of file timestamp.hpp.

Member Typedef Documentation

◆ base_type

◆ clock_type

using tim::component::timestamp::clock_type = std::chrono::system_clock

Definition at line 53 of file timestamp.hpp.

◆ duration_type

using tim::component::timestamp::duration_type = std::chrono::duration<clock_type::rep, std::nano>

Definition at line 55 of file timestamp.hpp.

◆ storage_type

Definition at line 66 of file declaration.hpp.

◆ time_point_type

using tim::component::timestamp::time_point_type = typename clock_type::time_point

Definition at line 54 of file timestamp.hpp.

◆ value_type

Member Function Documentation

◆ as_string()

std::string tim::component::timestamp::as_string ( const time_point_type _tp)
static

Definition at line 64 of file timestamp.cpp.

65{
66 char _repr[64];
67 std::memset(_repr, '\0', sizeof(_repr));
68 std::time_t _value = std::chrono::system_clock::to_time_t(_tp);
69 // alternative: "%c %Z"
70 if(std::strftime(_repr, sizeof(_repr), "%a %b %d %T %Y %Z", std::localtime(&_value)))
71 return std::string{ _repr };
72 return std::string{};
73}
tim::mpl::apply< std::string > string
Definition: macros.hpp:53

Referenced by tim::data::base::stream_entry::construct(), and get_display().

◆ count()

int64_t tim::component::timestamp::count ( )
static

Definition at line 77 of file timestamp.cpp.

78{
79 return std::chrono::duration_cast<duration_type>(record().time_since_epoch()).count();
80}
static value_type record()
Definition: timestamp.cpp:57

References record().

◆ description()

std::string tim::component::timestamp::description ( )
static

Definition at line 50 of file timestamp.cpp.

51{
52 return "Provides a timestamp for every sample and/or phase";
53}

◆ extra_serialization()

template<typename ArchiveT >
void tim::component::timestamp::extra_serialization ( ArchiveT &  ar)
static

Definition at line 108 of file timestamp.hpp.

109{
110 ar(cereal::make_nvp("reference_timestamp", get_reference_ts()));
111}
static value_type get_reference_ts()
Definition: timestamp.cpp:131

References get_reference_ts().

◆ get()

timestamp::value_type tim::component::timestamp::get ( ) const

Definition at line 100 of file timestamp.cpp.

101{
102 return base_type::get_value();
103}

◆ get_display()

std::string tim::component::timestamp::get_display ( ) const

Definition at line 107 of file timestamp.cpp.

108{
109 return as_string(base_type::get_value());
110}
static std::string as_string(const time_point_type &_tp)
Definition: timestamp.cpp:64

References as_string().

◆ get_opaque()

template<typename... Args>
static opaque tim::component::empty_base::get_opaque ( Args &&  ...)
inlinestaticinherited

Definition at line 72 of file declaration.hpp.

73 {
74 return opaque{};
75 }

◆ get_reference_ts()

timestamp::value_type tim::component::timestamp::get_reference_ts ( )
static

Definition at line 131 of file timestamp.cpp.

132{
133 static auto _v = record();
134 return _v;
135}

References record().

Referenced by extra_serialization(), sample(), and start().

◆ label()

std::string tim::component::timestamp::label ( )
static

Definition at line 43 of file timestamp.cpp.

44{
45 return "timestamp";
46}

◆ load()

template<typename ArchiveT >
void tim::component::timestamp::load ( ArchiveT &  ar,
const unsigned   
)

Definition at line 91 of file timestamp.hpp.

92{
93 time_t _val{};
94 ar(cereal::make_nvp("time_since_epoch", _val));
95 set_value(std::chrono::system_clock::from_time_t(_val));
96}

◆ operator+=()

timestamp & tim::component::timestamp::operator+= ( const timestamp _rhs)

Definition at line 114 of file timestamp.cpp.

115{
116 return (*this = _rhs);
117}

◆ operator/=() [1/2]

timestamp & tim::component::timestamp::operator/= ( const timestamp )

Definition at line 121 of file timestamp.cpp.

122{
123 return *this;
124}

◆ operator/=() [2/2]

timestamp & tim::component::timestamp::operator/= ( int64_t  )

Definition at line 127 of file timestamp.cpp.

127{ return *this; }

◆ record()

timestamp::value_type tim::component::timestamp::record ( )
static

Definition at line 57 of file timestamp.cpp.

58{
59 return std::chrono::system_clock::now();
60}

Referenced by count(), get_reference_ts(), sample(), and start().

◆ sample()

void tim::component::timestamp::sample ( )

Definition at line 84 of file timestamp.cpp.

85{
87 base_type::set_value(record());
88}

References get_reference_ts(), and record().

◆ save()

template<typename ArchiveT >
void tim::component::timestamp::save ( ArchiveT &  ar,
const unsigned   
) const

Definition at line 100 of file timestamp.hpp.

101{
102 auto _val = std::chrono::system_clock::to_time_t(get_value());
103 ar(cereal::make_nvp("time_since_epoch", _val));
104}

◆ start()

void tim::component::timestamp::start ( )

Definition at line 92 of file timestamp.cpp.

93{
95 base_type::set_value(record());
96}

References get_reference_ts(), and record().

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  _os,
const timestamp _ts 
)
friend

Definition at line 82 of file timestamp.hpp.

83 {
84 _os << _ts.get_display();
85 return _os;
86 }

The documentation for this struct was generated from the following files: