A Discrete-Event Network Simulator
API
system-wall-clock-timestamp.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Lawrence Livermore National Laboratory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
19  */
20 
22 
29 namespace ns3 {
30 
32  : m_last (0),
33  m_diff (0)
34 {
35  Stamp ();
36 }
37 
38 void
40 {
41  std::time_t seconds = std::time (NULL);
42  m_diff = seconds - m_last;
43  m_last = seconds;
44 }
45 
46 std::string
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
56 {
57  return m_last;
58 }
59 
60 std::time_t
62 {
63  return m_diff;
64 }
65 
66 
67 
68 } // namespace ns3
69 
std::time_t m_last
The last time stamp.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stamp(void)
Record the current wall-clock time and delta since the last stamp().
std::time_t GetInterval(void) const
Get the last recorded interval.
std::time_t GetLast(void) const
Get the last recorded raw value.
std::string ToString(void) const
Get the last time stamp as a string.
ns3::SystemWallClockTimestamp declaration.
std::time_t m_diff
Difference between the two previous time stamps.