17 _perf_graph(perf_graph),
18 _perf_graph_registry(
moose::internal::getPerfGraphRegistry()),
19 _execution_list(perf_graph._execution_list),
20 _currently_destructing(false),
21 _time_limit(perf_graph._live_print_time_limit),
22 _mem_limit(perf_graph._live_print_mem_limit),
24 _current_execution_list_end(0),
25 _current_execution_list_last(0),
26 _last_execution_list_end(0),
27 _last_printed_increment(NULL),
29 _console_num_printed(0),
30 _stack_top_print_dots(true)
49 !section_info._live_message.empty() ? section_info._live_message : section_info._name;
59 message =
"Currently " + message;
67 section_info._print_dots)
74 if (section_info._print_dots)
86 if (!section_info._print_dots)
97 if (!section_info._print_dots)
126 "Not found in map: " << section_increment_start.
_id);
131 auto message = !section_info_start.
_live_message.empty() ? section_info_start._live_message
132 : section_info_start._name;
134 auto time_increment =
135 std::chrono::duration<double>(section_increment_finish.
_time - section_increment_start.
_time)
138 auto memory_total = section_increment_finish.
_memory;
140 auto num_horizontal_chars = message.size() + (2 * section_increment_start.
_print_stack_level);
144 num_horizontal_chars +=
_app.
name().size() + 2;
148 if (!section_info_start._print_dots ||
163 num_horizontal_chars += 9;
166 num_horizontal_chars += section_increment_start.
_num_dots;
173 _console << std::setw(6) << std::fixed << std::setprecision(2) << time_increment <<
" s";
176 _console << COLOR_YELLOW << std::setw(5) << std::fixed;
249 auto next_p = p + 1 < MAX_EXECUTION_LIST_SIZE ? p + 1 : 0;
265 mooseAssert(
_stack_level,
"Popping beyond the beginning of the stack!");
271 auto time_increment =
272 std::chrono::duration<double>(section_increment._time - section_increment_start._time)
274 auto memory_increment = section_increment._memory - section_increment_start._memory;
279 time_increment >
_time_limit.load(std::memory_order_relaxed) ||
280 memory_increment >
_mem_limit.load(std::memory_order_relaxed))
284 printStats(section_increment_start, section_increment);
320 std::chrono::duration<Real>(
_time_limit.load(std::memory_order_relaxed)),
324 this->_currently_destructing = _perf_graph._destructing;
330 this->_current_execution_list_end =
331 _perf_graph._execution_list_end.load(std::memory_order_acquire);
334 this->_console_num_printed = _console.numPrinted();
337 return this->_currently_destructing ||
338 this->_last_execution_list_end != this->_current_execution_list_end;
351 : MAX_EXECUTION_LIST_SIZE;
An inteface for the _console for outputting to the Console object.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
unsigned long long int numPrinted() const
The number of times something has been printed.
Base class for MOOSE-based applications.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
const std::string & name() const
Get the name of the class.
bool _stack_top_print_dots
Whether or not the top thing on the stack is set to print dots.
std::atomic< bool > _currently_destructing
True when we stop printing.
void inSamePlace()
What to do if we're still in the same spot.
void start()
Start printing.
const unsigned int WRAP_LENGTH
Number of columns before wrapping.
unsigned long long int _last_num_printed
The output count from the console the last time we printed.
std::array< PerfGraph::SectionIncrement, MOOSE_MAX_STACK_SIZE > _print_thread_stack
The current stack for what the print thread has seen.
void iterateThroughExecutionList()
What to do if there are new things in the execution list.
std::atomic< unsigned int > & _mem_limit
Limit (in MB)
void printLiveMessage(PerfGraph::SectionIncrement §ion_increment)
Print the live message.
void printStackUpToLast()
Print everything underneath the current top of the stack.
unsigned int _current_execution_list_last
The actual last entry in the list This is useful because it is a circular queue - so this is not just...
unsigned long long int _console_num_printed
The current output count from the console.
PerfGraphLivePrint(PerfGraph &perf_graph, MooseApp &app)
unsigned int _last_execution_list_end
Where the end of the execution list was during the last call If this == the current_end....
const MooseApp & _app
The app performing this print.
void printStats(PerfGraph::SectionIncrement §ion_increment_start, PerfGraph::SectionIncrement §ion_increment_finish)
Print the stats.
std::atomic< Real > & _time_limit
Limit (in seconds) before printing.
PerfGraph::SectionIncrement * _last_printed_increment
Which increment was last printed.
unsigned int _current_execution_list_end
The end of the execution list This is (safely) copied from PerfGraph so that it is consistent for an ...
const moose::internal::PerfGraphRegistry & _perf_graph_registry
Reference to the PerfGraphRegistry for convenience.
unsigned int _stack_level
This is one beyond the last thing on the stack.
std::array< PerfGraph::SectionIncrement, MAX_EXECUTION_LIST_SIZE > & _execution_list
Convenience reference to the execution_list within the PerfGraph.
PerfGraph & _perf_graph
Reference to the PerfGraph to work with.
Use to hold an increment of time and memory for a section This is used in the LivePrint capability.
unsigned long long int _beginning_num_printed
The _console numPrinted() at the time this section was created.
unsigned int _print_stack_level
How much to indent this section.
long int _memory
Either the starting memory or final memory depending on _state.
std::chrono::time_point< std::chrono::steady_clock > _time
Either the starting time or final time depending on _state.
unsigned int _num_dots
How many dots have been printed for this section.
IncrementState _state
Whether or not this increment is the start of an increment or the finishing of an increment.
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode.
std::condition_variable _finished_section
The condition_variable to wake the print thread.
std::mutex _destructing_mutex
The mutex to use with a condition_variable predicate to guard _destructing.
@ PRINTED
This section has already started printing.
@ STARTED
Section just started running.
bool _live_print_all
Whether or not to put everything in the perf graph.
const PerfGraphSectionInfo & sectionInfo(const PerfID section_id) const
Given a PerfID return the PerfGraphSectionInfo @section_id The ID.
bool sectionExists(const std::string §ion_name) const
Whether or not a section with that name has been registered @section_name The name of the section.
std::string _live_message
Message to print while the section is running.
bool _print_dots
Whether or not to print dots while this section runs.