A Discrete-Event Network Simulator
API
show-progress.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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: Gustavo Carneiro <gjc@inescporto.pt>
18  * Author: Peter D. Barnes, Jr. <pdbarnes@llnl.gov>
19  */
20 
21 #ifndef SHOW_PROGRESS_H
22 #define SHOW_PROGRESS_H
23 
30 #include "event-id.h"
31 #include "nstime.h"
32 #include "system-wall-clock-ms.h"
34 #include "time-printer.h"
35 
36 #include <iostream>
37 
38 namespace ns3
39 {
40 
94 {
95  public:
101  ShowProgress(const Time interval = Seconds(1.0), std::ostream& os = std::cout);
102 
104  ~ShowProgress();
105 
110  void SetInterval(const Time interval);
111 
120  void SetTimePrinter(TimePrinter lp);
121 
126  void SetStream(std::ostream& os);
127 
133  void SetVerbose(bool verbose);
134 
135  private:
140  void Start();
141 
146  void Stop();
147 
151  void ScheduleCheckProgress();
152 
159  void CheckProgress();
160 
170  void GiveFeedback(uint64_t nEvents, int64x64_t ratio, int64x64_t speed);
171 
176  static const int64x64_t HYSTERESIS;
181  static const int64x64_t MAXGAIN;
182 
189  uint64_t m_eventCount;
190 
192  std::ostream* m_os;
193  bool m_verbose;
194  uint64_t m_repCount;
195 
196 }; // class ShowProgress
197 
198 } // namespace ns3
199 
200 #endif /* SHOW_PROGRESS_H */
An identifier for simulation events.
Definition: event-id.h:55
Periodically print a status message indicating simulator progress.
Definition: show-progress.h:94
bool m_verbose
Verbose mode flag.
void SetVerbose(bool verbose)
Set verbose mode to print real and virtual time intervals.
std::ostream * m_os
The output stream to use.
void Start()
Start the elapsed wallclock timestamp and print the start time.
void SetTimePrinter(TimePrinter lp)
Set the TimePrinter function to be used to prepend progress messages with the simulation time.
void Stop()
Stop the elapsed wallclock timestamp and print the total elapsed time.
ShowProgress(const Time interval=Seconds(1.0), std::ostream &os=std::cout)
Constructor.
Time m_interval
The target update interval, in wallclock time.
uint64_t m_repCount
Number of CheckProgress events.
~ShowProgress()
Destructor.
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.
void ScheduleCheckProgress()
Schedule the next CheckProgress.
EventId m_event
The next progress event.
void CheckProgress()
Check on execution progress.
TimePrinter m_printer
The TimePrinter to use.
SystemWallClockMs m_timer
Wallclock timer.
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:105
High precision numerical type, implementing Q64.64 fixed precision.
ns3::EventId declarations.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
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.