A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
system-wall-clock-timestamp.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Lawrence Livermore National Laboratory
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
7
*/
8
9
#include "
system-wall-clock-timestamp.h
"
10
11
/**
12
* \file
13
* \ingroup system
14
* ns3::SystemWallClockTimestamp implementation.
15
*/
16
17
namespace
ns3
18
{
19
20
SystemWallClockTimestamp::SystemWallClockTimestamp
()
21
: m_last(0),
22
m_diff(0)
23
{
24
Stamp
();
25
}
26
27
void
28
SystemWallClockTimestamp::Stamp
()
29
{
30
std::time_t seconds = std::time(
nullptr
);
31
m_diff
= seconds -
m_last
;
32
m_last
= seconds;
33
}
34
35
std::string
36
SystemWallClockTimestamp::ToString
()
const
37
{
38
std::string now = std::ctime(&
m_last
);
39
now.resize(now.length() - 1);
// trim trailing newline
40
return
now;
41
}
42
43
std::time_t
44
SystemWallClockTimestamp::GetLast
()
const
45
{
46
return
m_last
;
47
}
48
49
std::time_t
50
SystemWallClockTimestamp::GetInterval
()
const
51
{
52
return
m_diff
;
53
}
54
55
}
// namespace ns3
ns3::SystemWallClockTimestamp::GetInterval
std::time_t GetInterval() const
Get the last recorded interval.
Definition
system-wall-clock-timestamp.cc:50
ns3::SystemWallClockTimestamp::GetLast
std::time_t GetLast() const
Get the last recorded raw value.
Definition
system-wall-clock-timestamp.cc:44
ns3::SystemWallClockTimestamp::ToString
std::string ToString() const
Get the last time stamp as a string.
Definition
system-wall-clock-timestamp.cc:36
ns3::SystemWallClockTimestamp::SystemWallClockTimestamp
SystemWallClockTimestamp()
Constructor.
Definition
system-wall-clock-timestamp.cc:20
ns3::SystemWallClockTimestamp::m_diff
std::time_t m_diff
Difference between the two previous time stamps.
Definition
system-wall-clock-timestamp.h:59
ns3::SystemWallClockTimestamp::Stamp
void Stamp()
Record the current wall-clock time and delta since the last stamp().
Definition
system-wall-clock-timestamp.cc:28
ns3::SystemWallClockTimestamp::m_last
std::time_t m_last
The last time stamp.
Definition
system-wall-clock-timestamp.h:56
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
system-wall-clock-timestamp.h
ns3::SystemWallClockTimestamp declaration.
src
core
model
system-wall-clock-timestamp.cc
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0