mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-04-08 14:35:55 +02:00
Simplify special cases
This commit is contained in:
parent
8d2cc79b99
commit
887bf963af
@ -96,8 +96,9 @@ func NewUnit(unitStr string) Unit {
|
|||||||
// Special case for prefix 'p' or 'P' (Peta) and measures starting with 'p' or 'P'
|
// Special case for prefix 'p' or 'P' (Peta) and measures starting with 'p' or 'P'
|
||||||
// like 'packets' or 'percent'. Same for 'e' or 'E' (Exa) for measures starting with
|
// like 'packets' or 'percent'. Same for 'e' or 'E' (Exa) for measures starting with
|
||||||
// 'e' or 'E' like 'events'
|
// 'e' or 'E' like 'events'
|
||||||
if m == None && pre == Base {
|
if m == None {
|
||||||
if strings.ToLower(matches[1]) == "p" || strings.ToLower(matches[1]) == "e" {
|
switch pre {
|
||||||
|
case Peta, Exa:
|
||||||
t := NewMeasure(matches[1] + measures[0])
|
t := NewMeasure(matches[1] + measures[0])
|
||||||
if t != None {
|
if t != None {
|
||||||
m = t
|
m = t
|
||||||
@ -111,27 +112,7 @@ func NewUnit(unitStr string) Unit {
|
|||||||
}
|
}
|
||||||
// Special case for 'm' as prefix for Bytes as thers is nothing like MilliBytes
|
// Special case for 'm' as prefix for Bytes as thers is nothing like MilliBytes
|
||||||
switch m {
|
switch m {
|
||||||
case Bytes:
|
case Bytes, Flops, Packets, Events, Cycles, Requests:
|
||||||
if pre == Milli {
|
|
||||||
pre = Mega
|
|
||||||
}
|
|
||||||
case Flops:
|
|
||||||
if pre == Milli {
|
|
||||||
pre = Mega
|
|
||||||
}
|
|
||||||
case Packets:
|
|
||||||
if pre == Milli {
|
|
||||||
pre = Mega
|
|
||||||
}
|
|
||||||
case Events:
|
|
||||||
if pre == Milli {
|
|
||||||
pre = Mega
|
|
||||||
}
|
|
||||||
case Cycles:
|
|
||||||
if pre == Milli {
|
|
||||||
pre = Mega
|
|
||||||
}
|
|
||||||
case Requests:
|
|
||||||
if pre == Milli {
|
if pre == Milli {
|
||||||
pre = Mega
|
pre = Mega
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user