ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 5ccee64 was
1cb7fab2,
checked in by tdelisle <tdelisle@…>, 6 years ago
|
Added better support for enabling/disabling/compiling-out statistics
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[8f74a6a] | 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 | // |
---|
[675716e] | 7 | // Counter.cc -- |
---|
[8f74a6a] | 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> |
---|
[8e70823] | 20 | #include <functional> |
---|
[8f74a6a] | 21 | #include <iomanip> |
---|
| 22 | |
---|
| 23 | namespace Stats { |
---|
| 24 | namespace Counters { |
---|
| 25 | void print() { |
---|
[8e70823] | 26 | if(!top.head) return; |
---|
[8f74a6a] | 27 | size_t nc = 0; |
---|
[8e70823] | 28 | Base::ForAll(top, 0, [&](Base::TreeImpl * node, size_t level) { |
---|
[1cb7fab2] | 29 | nc = std::max(nc, (4 * level) + std::strlen(node->name)); |
---|
[8f74a6a] | 30 | }); |
---|
| 31 | |
---|
[1cb7fab2] | 32 | const char * const title = "Counter Statistic"; |
---|
[8f74a6a] | 33 | size_t nct = nc + 14; |
---|
| 34 | std::cerr << std::string(nct, '=') << std::endl; |
---|
[1cb7fab2] | 35 | std::cerr << std::string((nct - std::strlen(title)) / 2, ' '); |
---|
[8f74a6a] | 36 | std::cerr << title << std::endl; |
---|
| 37 | std::cerr << std::string(nct, '-') << std::endl; |
---|
| 38 | |
---|
| 39 | |
---|
[8e70823] | 40 | Base::ForAll(top, 0, [&](Base::TreeImpl * node, size_t level) { |
---|
[8f74a6a] | 41 | std::cerr << std::string(level * 4, ' '); |
---|
| 42 | std::cerr << node->name; |
---|
[1cb7fab2] | 43 | std::cerr << std::string(nc - ((level * 4) + std::strlen(node->name)), ' '); |
---|
[8f74a6a] | 44 | std::cerr << " | "; |
---|
| 45 | std::cerr << std::setw(9); |
---|
| 46 | node->print(std::cerr); |
---|
| 47 | std::cerr << " |"; |
---|
| 48 | std::cerr << '\n'; |
---|
[8e70823] | 49 | }, true); |
---|
[8f74a6a] | 50 | |
---|
| 51 | std::cerr << std::string(nct, '-') << std::endl; |
---|
| 52 | } |
---|
| 53 | |
---|
[1cb7fab2] | 54 | Base::TreeTop top; |
---|
| 55 | |
---|
| 56 | extern bool enabled; |
---|
[8f74a6a] | 57 | } |
---|
| 58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.