Skip to content

Commit

Permalink
metrics: remove uneeded syntax (ethereum#21921)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan authored and JukLee0ira committed Dec 20, 2024
1 parent da73a6b commit 6bb0f29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion metrics/cpu_syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// 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/>.

//go:build !windows
// +build !windows

package metrics
Expand All @@ -31,5 +32,5 @@ func getProcessCPUTime() int64 {
log.Warn("Failed to retrieve CPU time", "err", err)
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 changes: 6 additions & 6 deletions metrics/gauge_float64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@ func BenchmarkGuageFloat64(b *testing.B) {

func TestGaugeFloat64(t *testing.T) {
g := NewGaugeFloat64()
g.Update(float64(47.0))
if v := g.Value(); float64(47.0) != v {
g.Update(47.0)
if v := g.Value(); v != 47.0 {
t.Errorf("g.Value(): 47.0 != %v\n", v)
}
}

func TestGaugeFloat64Snapshot(t *testing.T) {
g := NewGaugeFloat64()
g.Update(float64(47.0))
g.Update(47.0)
snapshot := g.Snapshot()
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)
}
}

func TestGetOrRegisterGaugeFloat64(t *testing.T) {
r := NewRegistry()
NewRegisteredGaugeFloat64("foo", r).Update(float64(47.0))
NewRegisteredGaugeFloat64("foo", r).Update(47.0)
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)
}
}
Expand Down

0 comments on commit 6bb0f29

Please sign in to comment.