1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
/* Copyright (C) 2021-2023 Free Software Foundation, Inc.
Contributed by Oracle.
This file is part of GNU Binutils.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
#ifndef _METRIC_H
#define _METRIC_H
#include "dbe_structs.h"
#include "vec.h"
#include "enums.h"
#include "BaseMetric.h"
#define MAX_LEN 1024
class Expression;
// The metric class defines the metrics that are available. The metrics are
// registered when the experiment's log file is read.
class Metric : public BaseMetric
{
public:
typedef struct HistMetricS
{
int width;
int maxvalue_width;
int maxtime_width;
char legend1[MAX_LEN];
char legend2[MAX_LEN];
char legend3[MAX_LEN];
int indFirstExp; // only for -compare=[delta|ratio]
int indTimeVal; // only for HWC time-converted metrics
void update_max (struct HistMetricS *hm);
void init ();
} HistMetric;
Metric (const Metric& item); // copy constructor
Metric (BaseMetric *item, SubType st);
Metric (char *_name, SubType st); // for derived metrics
virtual ~Metric ();
char *get_mcmd (bool); // e.user, a.total, etc. NOTI18N
int get_real_visbits (); // methods for managing visibility
ValueTag get_vtype2 (); // takes comparison visbits into account
void set_dmetrics_visbits (int _dmetrics_visbits);
// fetch various fields from a Metric
SubType
get_subtype ()
{
return subtype;
}
char *
get_name ()
{
return name;
}
char *
get_abbr ()
{
return abbr;
}
char *
get_abbr_unit ()
{
return abbr_unit;
}
BaseMetric *
get_base_metric ()
{
return baseMetric;
}
int
get_visbits ()
{
return visbits;
}
void
set_raw_visbits (int _visbits)
{
visbits = _visbits;
}
void
clear_all_visbits ()
{
visbits = VAL_NA;
}
void
enable_all_visbits ()
{
visbits = get_value_styles ();
}
#define VAL_IS_HIDDEN(n) ((n) == -1 || (n) == VAL_NA || ((n) & VAL_HIDE_ALL) != 0)
bool
is_any_visible ()
{
return !VAL_IS_HIDDEN (visbits)
&& (visbits & (VAL_VALUE | VAL_TIMEVAL | VAL_PERCENT));
}
bool
is_value_visible ()
{
return (visbits & VAL_VALUE) != 0
|| (!is_time_val () && (visbits & VAL_TIMEVAL) != 0);
}
bool
is_time_visible ()
{
return is_time_val () && (visbits & VAL_TIMEVAL) != 0;
}
bool
is_visible ()
{
return !VAL_IS_HIDDEN (visbits) && is_value_visible ();
}
bool
is_tvisible ()
{
return !VAL_IS_HIDDEN (visbits) && is_time_visible ();
}
bool
is_pvisible ()
{
return !VAL_IS_HIDDEN (visbits) && (visbits & VAL_PERCENT) != 0;
}
bool
is_time_val ()
{
int v = VAL_TIMEVAL | VAL_VALUE;
return (get_value_styles () & v) == v;
}
// per-bit handling of visbits
// Note: Forces VAL_HIDE_ALL to zero. Use only on temporary Metric objects.
void set_vvisible (bool set);
void set_tvisible (bool set);
void set_pvisible (bool set);
void set_subtype (SubType st);
void legend_width (HistMetric *hitem, int gap);
char *get_vis_str ();
char *get_vis_string (int vis);
char *dump ();
private:
BaseMetric *baseMetric;
SubType subtype; // specific variant for this Metric
char *name;
char *abbr;
char *abbr_unit;
int visbits; // ValueType, e.g. VAL_VALUE|VAL_TIMEVAL
};
#endif /* _METRIC_H */
|