Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
c0343c8f
Commit
c0343c8f
authored
Jun 25, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: add memory stat collection too
parent
c6e2af14
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
main.go
cmd/geth/main.go
+24
-0
No files found.
cmd/geth/main.go
View file @
c0343c8f
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
"runtime"
"runtime"
"strconv"
"strconv"
"strings"
"strings"
"time"
"github.com/codegangsta/cli"
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
"github.com/ethereum/ethash"
...
@@ -42,6 +43,7 @@ import (
...
@@ -42,6 +43,7 @@ import (
"github.com/ethereum/go-ethereum/rpc/comms"
"github.com/ethereum/go-ethereum/rpc/comms"
"github.com/mattn/go-colorable"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"github.com/mattn/go-isatty"
"github.com/rcrowley/go-metrics"
)
)
const
(
const
(
...
@@ -285,6 +287,28 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
...
@@ -285,6 +287,28 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso
}
}
return
nil
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
()
{
func
main
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment