A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
system-wall-clock-timestamp.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 Lawrence Livermore National Laboratory
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
18
*/
19
20
#include "
system-wall-clock-timestamp.h
"
21
28
namespace
ns3
29
{
30
31
SystemWallClockTimestamp::SystemWallClockTimestamp
()
32
: m_last(0),
33
m_diff(0)
34
{
35
Stamp
();
36
}
37
38
void
39
SystemWallClockTimestamp::Stamp
()
40
{
41
std::time_t seconds = std::time(
nullptr
);
42
m_diff
= seconds -
m_last
;
43
m_last
= seconds;
44
}
45
46
std::string
47
SystemWallClockTimestamp::ToString
()
const
48
{
49
std::string now = std::ctime(&
m_last
);
50
now.resize(now.length() - 1);
// trim trailing newline
51
return
now;
52
}
53
54
std::time_t
55
SystemWallClockTimestamp::GetLast
()
const
56
{
57
return
m_last
;
58
}
59
60
std::time_t
61
SystemWallClockTimestamp::GetInterval
()
const
62
{
63
return
m_diff
;
64
}
65
66
}
// namespace ns3
ns3::SystemWallClockTimestamp::GetInterval
std::time_t GetInterval() const
Get the last recorded interval.
Definition:
system-wall-clock-timestamp.cc:61
ns3::SystemWallClockTimestamp::GetLast
std::time_t GetLast() const
Get the last recorded raw value.
Definition:
system-wall-clock-timestamp.cc:55
ns3::SystemWallClockTimestamp::ToString
std::string ToString() const
Get the last time stamp as a string.
Definition:
system-wall-clock-timestamp.cc:47
ns3::SystemWallClockTimestamp::SystemWallClockTimestamp
SystemWallClockTimestamp()
Constructor.
Definition:
system-wall-clock-timestamp.cc:31
ns3::SystemWallClockTimestamp::m_diff
std::time_t m_diff
Difference between the two previous time stamps.
Definition:
system-wall-clock-timestamp.h:70
ns3::SystemWallClockTimestamp::Stamp
void Stamp()
Record the current wall-clock time and delta since the last stamp().
Definition:
system-wall-clock-timestamp.cc:39
ns3::SystemWallClockTimestamp::m_last
std::time_t m_last
The last time stamp.
Definition:
system-wall-clock-timestamp.h:67
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 Sun Mar 3 2024 17:10:55 for ns-3 by
1.9.1