aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-06-25 18:47:06 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-06-25 18:47:06 +0800
commitc0343c8f17de0b896d4c0546921881a92ce4ae1a (patch)
tree7844ea0e9e4089ac81b06f7841e4c87960accaad
parentc6e2af14c0019c43c11e03b9fd79ba4489a38bed (diff)
downloadgo-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.tar
go-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.tar.gz
go-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.tar.bz2
go-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.tar.lz
go-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.tar.xz
go-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.tar.zst
go-tangerine-c0343c8f17de0b896d4c0546921881a92ce4ae1a.zip
cmd/geth: add memory stat collection too
-rw-r--r--cmd/geth/main.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index f1c229d1f..53f6a95d9 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -30,6 +30,7 @@ import (
"runtime"
"strconv"
"strings"
+ "time"
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
@@ -42,6 +43,7 @@ import (
"github.com/ethereum/go-ethereum/rpc/comms"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
+ "github.com/rcrowley/go-metrics"
)
const (
@@ -285,6 +287,28 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
}
return nil
}
+ // Start system runtime metrics collection
+ go func() {
+ used := metrics.GetOrRegisterMeter("system/memory/used", metrics.DefaultRegistry)
+ total := metrics.GetOrRegisterMeter("system/memory/total", metrics.DefaultRegistry)
+ mallocs := metrics.GetOrRegisterMeter("system/memory/mallocs", metrics.DefaultRegistry)
+ frees := metrics.GetOrRegisterMeter("system/memory/frees", metrics.DefaultRegistry)
+
+ stats := make([]*runtime.MemStats, 2)
+ for i := 0; i < len(stats); i++ {
+ stats[i] = new(runtime.MemStats)
+ }
+ for i := 1; ; i++ {
+ runtime.ReadMemStats(stats[i%2])
+
+ used.Mark(int64(stats[i%2].Alloc - stats[(i-1)%2].Alloc))
+ total.Mark(int64(stats[i%2].TotalAlloc - stats[(i-1)%2].TotalAlloc))
+ mallocs.Mark(int64(stats[i%2].Mallocs - stats[(i-1)%2].Mallocs))
+ frees.Mark(int64(stats[i%2].Frees - stats[(i-1)%2].Frees))
+
+ time.Sleep(3 * time.Second)
+ }
+ }()
}
func main() {