ADTast-experimental
Last change
on this file since 9317419 was
57e0289,
checked in by Thierry Delisle <tdelisle@…>, 4 years ago
|
Added stats option to print stats per expression in new-ast resolution
|
-
Property mode set to
100644
|
File size:
1.6 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 | // Stats.cc -- |
---|
8 | // |
---|
9 | // Author : Thierry Delisle |
---|
10 | // Created On : Fri Mar 01 15:45:08 2019 |
---|
11 | // Last Modified By : |
---|
12 | // Last Modified On : |
---|
13 | // Update Count : |
---|
14 | // |
---|
15 | |
---|
16 | #include <iostream> |
---|
17 | #include <sstream> |
---|
18 | #include <string> |
---|
19 | |
---|
20 | |
---|
21 | namespace Stats { |
---|
22 | namespace Counters { |
---|
23 | bool enabled = false; |
---|
24 | void print(); |
---|
25 | } |
---|
26 | |
---|
27 | namespace Heap { |
---|
28 | bool enabled = false; |
---|
29 | void print(); |
---|
30 | } |
---|
31 | |
---|
32 | namespace Time { |
---|
33 | bool enabled = false; |
---|
34 | void print(); |
---|
35 | } |
---|
36 | |
---|
37 | namespace ResolveTime { |
---|
38 | bool enabled = false; |
---|
39 | } |
---|
40 | |
---|
41 | struct { |
---|
42 | const char * const opt; |
---|
43 | bool & enabled; |
---|
44 | } |
---|
45 | statistics[] = { |
---|
46 | { "counters", Counters::enabled }, |
---|
47 | { "heap" , Heap::enabled }, |
---|
48 | { "time" , Time::enabled }, |
---|
49 | { "resolve" , ResolveTime::enabled }, |
---|
50 | }; |
---|
51 | |
---|
52 | void set_param(std::string & param) { |
---|
53 | if(param == "all") { |
---|
54 | for(auto & stat : statistics) { |
---|
55 | stat.enabled = true; |
---|
56 | } |
---|
57 | return; |
---|
58 | } |
---|
59 | |
---|
60 | if(param == "none") { |
---|
61 | for(auto & stat : statistics) { |
---|
62 | stat.enabled = false; |
---|
63 | } |
---|
64 | return; |
---|
65 | } |
---|
66 | |
---|
67 | for(auto & stat : statistics) { |
---|
68 | if(stat.opt == param) { |
---|
69 | stat.enabled = true; |
---|
70 | return; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | std::cerr << "Ignoring unknown statistic " << param << std::endl; |
---|
75 | } |
---|
76 | |
---|
77 | void parse_params(const char * const params) { |
---|
78 | std::stringstream ss(params); |
---|
79 | while(ss.good()) { |
---|
80 | std::string substr; |
---|
81 | getline( ss, substr, ',' ); |
---|
82 | set_param(substr); |
---|
83 | } |
---|
84 | } |
---|
85 | |
---|
86 | void print() { |
---|
87 | Counters::print(); |
---|
88 | Heap::print(); |
---|
89 | Time::print(); |
---|
90 | } |
---|
91 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.