A Discrete-Event Network Simulator
API
show-progress.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 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: Gustavo Carneiro <gjc@inescporto.pt>
19  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
20  */
21 
22 
23 #ifndef SHOW_PROGRESS_H
24 #define SHOW_PROGRESS_H
25 
32 #include <iostream>
33 
34 #include "event-id.h"
35 #include "nstime.h"
36 #include "system-wall-clock-ms.h"
38 #include "time-printer.h"
39 
40 namespace ns3 {
41 
42 
96 {
97 public:
103  ShowProgress (const Time interval = Seconds (1.0),
104  std::ostream & os = std::cout);
105 
107  ~ShowProgress (void);
108 
113  void SetInterval (const Time interval);
114 
123  void SetTimePrinter (TimePrinter lp);
124 
129  void SetStream (std::ostream & os);
130 
136  void SetVerbose (bool verbose);
137 
138 private:
139 
144  void Start (void);
145 
150  void Stop (void);
151 
155  void ScheduleCheckProgress (void);
156 
163  void CheckProgress (void);
164 
174  void GiveFeedback (uint64_t nEvents, int64x64_t ratio, int64x64_t speed);
175 
180  static const int64x64_t HYSTERESIS;
185  static const int64x64_t MAXGAIN;
186 
193  uint64_t m_eventCount;
194 
196  std::ostream *m_os;
197  bool m_verbose;
198  uint64_t m_repCount;
199 
200 }; // class ShowProgress
201 
202 } // namespace ns3
203 
204 #endif /* SHOW_PROGRESS_H */
An identifier for simulation events.
Definition: event-id.h:54
Periodically print a status message indicating simulator progress.
Definition: show-progress.h:96
bool m_verbose
Verbose mode flag.
void SetVerbose(bool verbose)
Set verbose mode to print real and virtual time intervals.
void Start(void)
Start the elapsed wallclock timestamp and print the start time.
std::ostream * m_os
The output stream to use.
void Stop(void)
Stop the elapsed wallclock timestamp and print the total elapsed time.
void SetTimePrinter(TimePrinter lp)
Set the TimePrinter function to be used to prepend progress messages with the simulation time.
ShowProgress(const Time interval=Seconds(1.0), std::ostream &os=std::cout)
Constructor.
Time m_interval
The target update interval, in wallclock time.
void CheckProgress(void)
Check on execution progress.
uint64_t m_repCount
Number of CheckProgress events.
void GiveFeedback(uint64_t nEvents, int64x64_t ratio, int64x64_t speed)
Show execution progress.
void SetStream(std::ostream &os)
Set the output stream to show progress on.
static const int64x64_t MAXGAIN
Maximum growth factor.
SystemWallClockTimestamp m_stamp
Elapsed wallclock time.
Time m_elapsed
Total elapsed wallclock time since last update.
Time m_vtime
The virtual time interval.
EventId m_event
The next progress event.
TimePrinter m_printer
The TimePrinter to use.
SystemWallClockMs m_timer
Wallclock timer.
void ScheduleCheckProgress(void)
Schedule the next CheckProgress.
~ShowProgress(void)
Destructor.
void SetInterval(const Time interval)
Set the target update interval, in wallclock time.
static const int64x64_t HYSTERESIS
Hysteresis factor.
uint64_t m_eventCount
Simulator event count.
Measure elapsed wall clock time in milliseconds.
Utility class to record the difference between two wall-clock times.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
High precision numerical type, implementing Q64.64 fixed precision.
Definition: int64x64-128.h:56
ns3::EventId declarations.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void(* TimePrinter)(std::ostream &os)
Function signature for features requiring a time formatter, such as logging or ShowProgress.
Definition: time-printer.h:43
Declaration of classes ns3::Time and ns3::TimeWithUnit, and the TimeValue implementation classes.
bool verbose
ns3::SystemWallClockMs declaration.
ns3::SystemWallClockTimestamp declaration.
Declaration of ns3::TimePrinter function pointer type and ns3::DefaultTimePrinter function.