ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpersistent-indexerpthread-emulationqualifiedEnum
Last change
on this file since c9e640e was
8f74a6a,
checked in by tdelisle <tdelisle@…>, 6 years ago
|
Added code to support generic statistic counters in the compiler
|
-
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 | size_t nc = 0; |
---|
38 | ForAllCounters(BaseCounter::top, 0, [&](BaseCounter * node, size_t level) { |
---|
39 | nc = std::max(nc, (4 * level) + std::strlen(node->name)); |
---|
40 | }); |
---|
41 | |
---|
42 | const char * const title = "Counter Statistic"; |
---|
43 | size_t nct = nc + 14; |
---|
44 | std::cerr << std::string(nct, '=') << std::endl; |
---|
45 | std::cerr << std::string((nct - std::strlen(title)) / 2, ' '); |
---|
46 | std::cerr << title << std::endl; |
---|
47 | std::cerr << std::string(nct, '-') << std::endl; |
---|
48 | |
---|
49 | |
---|
50 | ForAllCounters(BaseCounter::top, 0, [&](BaseCounter * node, size_t level) { |
---|
51 | std::cerr << std::string(level * 4, ' '); |
---|
52 | std::cerr << node->name; |
---|
53 | std::cerr << std::string(nc - ((level * 4) + std::strlen(node->name)), ' '); |
---|
54 | std::cerr << " | "; |
---|
55 | std::cerr << std::setw(9); |
---|
56 | node->print(std::cerr); |
---|
57 | std::cerr << " |"; |
---|
58 | std::cerr << '\n'; |
---|
59 | delete node; |
---|
60 | }); |
---|
61 | |
---|
62 | std::cerr << std::string(nct, '-') << std::endl; |
---|
63 | } |
---|
64 | |
---|
65 | BaseCounter::list_t BaseCounter::top; |
---|
66 | } |
---|
67 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.