mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
metrics: remove uneeded syntax (#21921)
This commit is contained in:
parent
9d082aa38c
commit
1a844e4578
2 changed files with 8 additions and 7 deletions
|
|
@ -14,6 +14,7 @@
|
||||||
// You should have received a copy of the GNU Lesser General Public License
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//go:build !windows
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
package metrics
|
package metrics
|
||||||
|
|
@ -31,5 +32,5 @@ func getProcessCPUTime() int64 {
|
||||||
log.Warn("Failed to retrieve CPU time", "err", err)
|
log.Warn("Failed to retrieve CPU time", "err", err)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return int64(usage.Utime.Sec+usage.Stime.Sec)*100 + int64(usage.Utime.Usec+usage.Stime.Usec)/10000 //nolint:unconvert
|
return (usage.Utime.Sec+usage.Stime.Sec)*100 + int64(usage.Utime.Usec+usage.Stime.Usec)/10000 //nolint:unconvert
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,27 +12,27 @@ func BenchmarkGuageFloat64(b *testing.B) {
|
||||||
|
|
||||||
func TestGaugeFloat64(t *testing.T) {
|
func TestGaugeFloat64(t *testing.T) {
|
||||||
g := NewGaugeFloat64()
|
g := NewGaugeFloat64()
|
||||||
g.Update(float64(47.0))
|
g.Update(47.0)
|
||||||
if v := g.Value(); float64(47.0) != v {
|
if v := g.Value(); v != 47.0 {
|
||||||
t.Errorf("g.Value(): 47.0 != %v\n", v)
|
t.Errorf("g.Value(): 47.0 != %v\n", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGaugeFloat64Snapshot(t *testing.T) {
|
func TestGaugeFloat64Snapshot(t *testing.T) {
|
||||||
g := NewGaugeFloat64()
|
g := NewGaugeFloat64()
|
||||||
g.Update(float64(47.0))
|
g.Update(47.0)
|
||||||
snapshot := g.Snapshot()
|
snapshot := g.Snapshot()
|
||||||
g.Update(float64(0))
|
g.Update(float64(0))
|
||||||
if v := snapshot.Value(); float64(47.0) != v {
|
if v := snapshot.Value(); v != 47.0 {
|
||||||
t.Errorf("g.Value(): 47.0 != %v\n", v)
|
t.Errorf("g.Value(): 47.0 != %v\n", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetOrRegisterGaugeFloat64(t *testing.T) {
|
func TestGetOrRegisterGaugeFloat64(t *testing.T) {
|
||||||
r := NewRegistry()
|
r := NewRegistry()
|
||||||
NewRegisteredGaugeFloat64("foo", r).Update(float64(47.0))
|
NewRegisteredGaugeFloat64("foo", r).Update(47.0)
|
||||||
t.Logf("registry: %v", r)
|
t.Logf("registry: %v", r)
|
||||||
if g := GetOrRegisterGaugeFloat64("foo", r); float64(47.0) != g.Value() {
|
if g := GetOrRegisterGaugeFloat64("foo", r); g.Value() != 47.0 {
|
||||||
t.Fatal(g)
|
t.Fatal(g)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue