Cadabra
Computer algebra system for field theory problems
ProgressMonitor.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <string>
5 #include <chrono>
6 #include <stack>
7 #include <map>
8 #include <vector>
9 
11  public:
13  virtual ~ProgressMonitor();
14 
15  void group(std::string name="");
16  void progress(int n, int total);
17 
18  void print() const;
19 
20  class Total {
21  public:
22  Total();
23 
24  std::string name;
25  size_t call_count;
26  std::chrono::milliseconds time_spent;
28 
29  long time_spent_as_long() const;
30 
31  bool operator==(const Total& other) const;
32 
33  std::string str() const;
34  };
35 
36  std::vector<Total> totals() const;
37 
38  private:
39  class Block {
40  public:
41  Block();
42 
43  std::string name;
44  std::chrono::milliseconds started;
46  };
47 
48  std::stack<Block> call_stack;
49  std::map<std::string, Total> call_totals;
50  };
51 
52 
ProgressMonitor::Total::call_count
size_t call_count
Definition: ProgressMonitor.hh:25
ProgressMonitor
Definition: ProgressMonitor.hh:10
ProgressMonitor::group
void group(std::string name="")
Definition: ProgressMonitor.cc:33
ProgressMonitor::call_stack
std::stack< Block > call_stack
Definition: ProgressMonitor.hh:48
ProgressMonitor::Block::step
int step
Definition: ProgressMonitor.hh:45
ProgressMonitor::Block::total_steps
int total_steps
Definition: ProgressMonitor.hh:45
ProgressMonitor::progress
void progress(int n, int total)
Definition: ProgressMonitor.cc:67
ProgressMonitor::print
void print() const
Definition: ProgressMonitor.cc:78
ProgressMonitor::ProgressMonitor
ProgressMonitor()
Definition: ProgressMonitor.cc:6
ProgressMonitor::Block
Definition: ProgressMonitor.hh:39
ProgressMonitor::~ProgressMonitor
virtual ~ProgressMonitor()
Definition: ProgressMonitor.cc:10
ProgressMonitor::Total
Definition: ProgressMonitor.hh:20
ProgressMonitor::Total::operator==
bool operator==(const Total &other) const
Definition: ProgressMonitor.cc:98
ProgressMonitor::Block::name
std::string name
Definition: ProgressMonitor.hh:43
ProgressMonitor::Total::time_spent_as_long
long time_spent_as_long() const
Definition: ProgressMonitor.cc:73
ProgressMonitor::Total::name
std::string name
Definition: ProgressMonitor.hh:24
ProgressMonitor::call_totals
std::map< std::string, Total > call_totals
Definition: ProgressMonitor.hh:49
ProgressMonitor::Total::Total
Total()
Definition: ProgressMonitor.cc:20
ProgressMonitor::Total::total_steps
int total_steps
Definition: ProgressMonitor.hh:27
ProgressMonitor::totals
std::vector< Total > totals() const
Definition: ProgressMonitor.cc:89
ProgressMonitor::Total::time_spent
std::chrono::milliseconds time_spent
Definition: ProgressMonitor.hh:26
ProgressMonitor::Block::Block
Block()
Definition: ProgressMonitor.cc:14
ProgressMonitor::Block::started
std::chrono::milliseconds started
Definition: ProgressMonitor.hh:44
ProgressMonitor::Total::str
std::string str() const
Definition: ProgressMonitor.cc:25