forked from idaholab/moose
/
PerfGraphLivePrint.h
70 lines (47 loc) · 1.93 KB
/
PerfGraphLivePrint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html
#pragma once
#include "PerfGraph.h"
class PerfGraphLivePrint : protected ConsoleStreamInterface
{
public:
PerfGraphLivePrint(PerfGraph & perf_graph, MooseApp & app);
/// Start printing
void start();
protected:
// Print the live message
void printLiveMessage(PerfGraph::SectionIncrement & section_increment);
// Print the stats
void printStats(PerfGraph::SectionIncrement & section_increment_start, PerfGraph::SectionIncrement & section_increment_finish);
// Print everything in the stack
void printStack();
// Print everything underneath the current top of the stack
void printStackUpToLast();
// What to do if we're still in the same spot
void inSamePlace();
// What to do if there are new things in the execution list
void iterateThroughExecutionList();
const unsigned int WRAP_LENGTH = 90;
PerfGraph & _perf_graph;
std::array<PerfGraph::SectionIncrement, MAX_EXECUTION_LIST_SIZE> & _execution_list;
std::future<bool> _done_future;
std::map<PerfID, PerfGraph::SectionInfo> & _id_to_section_info;
/// This is one beyond the last thing on the stack
unsigned int _stack_level;
/// The current stack for what the print thread has seen
std::array<PerfGraph::SectionIncrement *, MAX_STACK_SIZE> _print_thread_stack;
unsigned int _current_execution_list_end;
unsigned int _current_execution_list_last;
unsigned int _last_execution_list_end;
PerfGraph::SectionIncrement * _last_printed_increment;
/// The output count from the console the last time we printed
unsigned long long int _last_num_printed;
/// Whether or not printing happened in this iteration
bool _printed;
};