17 _perf_graph(perf_graph),
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)
42 section_increment.
_state = PerfGraph::IncrementState::PRINTED;
49 !section_info._live_message.empty() ? section_info._live_message : section_info._name;
56 section_increment.
_state == PerfGraph::IncrementState::STARTED &&
59 message =
"Currently " + message;
67 section_info._print_dots)
72 section_increment.
_state == PerfGraph::IncrementState::PRINTED)
74 if (section_info._print_dots)
81 else if (section_increment.
_state == PerfGraph::IncrementState::PRINTED)
86 if (!section_info._print_dots)
97 if (!section_info._print_dots)
101 if (section_increment.
_state != PerfGraph::IncrementState::STARTED ||
107 section_increment.
_state = PerfGraph::IncrementState::PRINTED;
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;
202 if (section._state == PerfGraph::IncrementState::STARTED)
205 section._state = PerfGraph::IncrementState::PRINTED;
249 auto next_p = p + 1 < MAX_EXECUTION_LIST_SIZE ? p + 1 : 0;
254 if (section_increment._state == PerfGraph::IncrementState::STARTED)
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;
278 section_increment_start._state == PerfGraph::IncrementState::PRINTED ||
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)),
351 : MAX_EXECUTION_LIST_SIZE;
PerfGraph::SectionIncrement * _last_printed_increment
Which increment was last printed.
unsigned long long int _last_num_printed
The output count from the console the last time we printed.
long int _memory
Either the starting memory or final memory depending on _state.
bool _stack_top_print_dots
Whether or not the top thing on the stack is set to print dots.
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
std::string _live_message
Message to print while the section is running.
bool sectionExists(const std::string §ion_name) const
Whether or not a section with that name has been registered The name of the section.
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 ...
void iterateThroughExecutionList()
What to do if there are new things in the execution list.
Base class for MOOSE-based applications.
Use to hold an increment of time and memory for a section This is used in the LivePrint capability...
std::atomic< unsigned int > _execution_list_end
Where the print thread should stop reading the execution list.
unsigned int _print_stack_level
How much to indent this section.
const unsigned int WRAP_LENGTH
Number of columns before wrapping.
PerfGraphLivePrint(PerfGraph &perf_graph, MooseApp &app)
bool _live_print_all
Whether or not to put everything in the perf graph.
std::condition_variable _finished_section
The condition_variable to wake the print thread.
virtual const std::string & name() const
Get the name of the class.
std::atomic< bool > _currently_destructing
True when we stop printing.
IncrementState _state
Whether or not this increment is the start of an increment or the finishing of an increment...
std::array< PerfGraph::SectionIncrement, MOOSE_MAX_STACK_SIZE > _print_thread_stack
The current stack for what the print thread has seen.
std::array< PerfGraph::SectionIncrement, MAX_EXECUTION_LIST_SIZE > & _execution_list
Convenience reference to the execution_list within the PerfGraph.
unsigned int _last_execution_list_end
Where the end of the execution list was during the last call If this == the current_end...
unsigned long long int numPrinted() const
The number of times something has been printed.
void printStats(PerfGraph::SectionIncrement §ion_increment_start, PerfGraph::SectionIncrement §ion_increment_finish)
Print the stats.
unsigned long long int _beginning_num_printed
The _console numPrinted() at the time this section was created.
unsigned int _num_dots
How many dots have been printed for this section.
std::mutex _destructing_mutex
The mutex to use with a condition_variable predicate to guard _destructing.
An inteface for the _console for outputting to the Console object.
const PerfGraphSectionInfo & sectionInfo(const PerfID section_id) const
Given a PerfID return the PerfGraphSectionInfo The ID.
std::atomic< unsigned int > & _mem_limit
Limit (in MB)
const MooseApp & _app
The app performing this print.
bool _print_dots
Whether or not to print dots while this section runs.
std::chrono::time_point< std::chrono::steady_clock > _time
Either the starting time or final time depending on _state.
PerfGraph & _perf_graph
Reference to the PerfGraph to work with.
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.
void start()
Start printing.
const moose::internal::PerfGraphRegistry & _perf_graph_registry
Reference to the PerfGraphRegistry for convenience.
bool _destructing
Tell the print thread to teardown.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
void printStackUpToLast()
Print everything underneath the current top of the stack.
void printLiveMessage(PerfGraph::SectionIncrement §ion_increment)
Print the live message.
void inSamePlace()
What to do if we're still in the same spot.
unsigned int _stack_level
This is one beyond the last thing on the stack.
The PerfGraph will hold the master list of all registered performance segments and the head PerfNode...
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.
std::atomic< Real > & _time_limit
Limit (in seconds) before printing.