source:
src/Common/Stats/Counter.cc@
3f9a8d0
Last change on this file since 3f9a8d0 was 1cb7fab2, checked in by , 7 years ago | |
---|---|
|
|
File size: 1.4 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 | // Counter.cc -- |
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 <functional> |
21 | #include <iomanip> |
22 | |
23 | namespace Stats { |
24 | namespace Counters { |
25 | void print() { |
26 | if(!top.head) return; |
27 | size_t nc = 0; |
28 | Base::ForAll(top, 0, [&](Base::TreeImpl * node, size_t level) { |
29 | nc = std::max(nc, (4 * level) + std::strlen(node->name)); |
30 | }); |
31 | |
32 | const char * const title = "Counter Statistic"; |
33 | size_t nct = nc + 14; |
34 | std::cerr << std::string(nct, '=') << std::endl; |
35 | std::cerr << std::string((nct - std::strlen(title)) / 2, ' '); |
36 | std::cerr << title << std::endl; |
37 | std::cerr << std::string(nct, '-') << std::endl; |
38 | |
39 | |
40 | Base::ForAll(top, 0, [&](Base::TreeImpl * node, size_t level) { |
41 | std::cerr << std::string(level * 4, ' '); |
42 | std::cerr << node->name; |
43 | std::cerr << std::string(nc - ((level * 4) + std::strlen(node->name)), ' '); |
44 | std::cerr << " | "; |
45 | std::cerr << std::setw(9); |
46 | node->print(std::cerr); |
47 | std::cerr << " |"; |
48 | std::cerr << '\n'; |
49 | }, true); |
50 | |
51 | std::cerr << std::string(nct, '-') << std::endl; |
52 | } |
53 | |
54 | Base::TreeTop top; |
55 | |
56 | extern bool enabled; |
57 | } |
58 | } |
Note:
See TracBrowser
for help on using the repository browser.