ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
persistent-indexer
pthread-emulation
qualifiedEnum
Last change
on this file since ca0f061f was a1099278, checked in by tdelisle <tdelisle@…>, 7 years ago |
Fix printing of empty counters
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // Heap.h --
|
---|
8 | //
|
---|
9 | // Author : Thierry Delisle
|
---|
10 | // Created On : Thu Feb 28 13::27:10 2019
|
---|
11 | // Last Modified By :
|
---|
12 | // Last Modified On :
|
---|
13 | // Update Count :
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include "Counter.h"
|
---|
17 |
|
---|
18 | #include <algorithm>
|
---|
19 | #include <cstring>
|
---|
20 | #include <iomanip>
|
---|
21 |
|
---|
22 | namespace Stats {
|
---|
23 | namespace Counters {
|
---|
24 |
|
---|
25 | template<typename T>
|
---|
26 | void ForAllCounters(BaseCounter::list_t & range, size_t level, T func) {
|
---|
27 | auto it = range.head;
|
---|
28 | while(it) {
|
---|
29 | auto next = it->next;
|
---|
30 | func(it, level);
|
---|
31 | ForAllCounters(it->children, level + 1, func);
|
---|
32 | it = next;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | void print() {
|
---|
37 | if(!BaseCounter::top.head) return;
|
---|
38 | size_t nc = 0;
|
---|
39 | ForAllCounters(BaseCounter::top, 0, [&](BaseCounter * node, size_t level) {
|
---|
40 | nc = std::max(nc, (4 * level) + std::strlen(node->name));
|
---|
41 | });
|
---|
42 |
|
---|
43 | const char * const title = "Counter Statistic";
|
---|
44 | size_t nct = nc + 14;
|
---|
45 | std::cerr << std::string(nct, '=') << std::endl;
|
---|
46 | std::cerr << std::string((nct - std::strlen(title)) / 2, ' ');
|
---|
47 | std::cerr << title << std::endl;
|
---|
48 | std::cerr << std::string(nct, '-') << std::endl;
|
---|
49 |
|
---|
50 |
|
---|
51 | ForAllCounters(BaseCounter::top, 0, [&](BaseCounter * node, size_t level) {
|
---|
52 | std::cerr << std::string(level * 4, ' ');
|
---|
53 | std::cerr << node->name;
|
---|
54 | std::cerr << std::string(nc - ((level * 4) + std::strlen(node->name)), ' ');
|
---|
55 | std::cerr << " | ";
|
---|
56 | std::cerr << std::setw(9);
|
---|
57 | node->print(std::cerr);
|
---|
58 | std::cerr << " |";
|
---|
59 | std::cerr << '\n';
|
---|
60 | delete node;
|
---|
61 | });
|
---|
62 |
|
---|
63 | std::cerr << std::string(nct, '-') << std::endl;
|
---|
64 | }
|
---|
65 |
|
---|
66 | BaseCounter::list_t BaseCounter::top;
|
---|
67 | }
|
---|
68 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.