source: src/Common/Stats/Counter.cc @ 675716e

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since 675716e was 675716e, checked in by tdelisle <tdelisle@…>, 5 years ago

Instrumented PassVisitor? to print average/max depth

  • Property mode set to 100644
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
23namespace 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) + node->name.size());
30                        });
31
32                        const std::string & title = "Counter Statistic";
33                        size_t nct = nc + 14;
34                        std::cerr << std::string(nct, '=') << std::endl;
35                        std::cerr << std::string((nct - title.size()) / 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) + node->name.size()), ' ');
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::TreeImpl::Top top;
55        }
56}
Note: See TracBrowser for help on using the repository browser.