Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Vladimir Barsukov
zGo
Commits
41f388bf
Commit
41f388bf
authored
1 year ago
by
Vladimir Barsukov
Browse files
Options
Download
Email Patches
Plain Diff
fix
parent
c76eb20c
master
v1.6.3
v1.6.2
v1.6.1
v1.6.0
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.1
v1.3.0
v1.2.1
v1.2.0
v1.1.1
v1.1.0
v1.0.9
v1.0.8
v1.0.7
v1.0.6
v1.0.5
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zdebug/zdebug.go
+22
-16
zdebug/zdebug.go
with
22 additions
and
16 deletions
+22
-16
zdebug/zdebug.go
+
22
-
16
View file @
41f388bf
...
@@ -2,7 +2,6 @@ package zdebug
...
@@ -2,7 +2,6 @@ package zdebug
import
(
import
(
"fmt"
"fmt"
"git.barsukov.pro/barsukov/zgo/zjson"
"git.barsukov.pro/barsukov/zgo/zutils"
"git.barsukov.pro/barsukov/zgo/zutils"
"runtime"
"runtime"
"strings"
"strings"
...
@@ -10,32 +9,39 @@ import (
...
@@ -10,32 +9,39 @@ import (
)
)
type
Monitor
struct
{
type
Monitor
struct
{
Alloc
,
Alloc
uint64
`json:",omitempty"`
Sys
,
HeapInuse
uint64
`json:",omitempty"`
LiveObjects
uint64
MaxAlloc
uint64
`json:",omitempty"`
MaxSys
uint64
`json:",omitempty"`
NumGC
uint32
LiveObjects
uint64
`json:",omitempty"`
NumGoroutine
int
NumGC
uint32
`json:",omitempty"`
NumGoroutine
int
`json:",omitempty"`
}
}
const
mb
=
1024
*
1024
func
NewMonitor
(
secs
int
)
{
func
NewMonitor
(
secs
int
)
{
go
func
()
{
go
func
()
{
var
m
Monitor
var
rtm
runtime
.
MemStats
var
rtm
runtime
.
MemStats
var
interval
=
time
.
Duration
(
secs
)
*
time
.
Second
var
memMax
uint64
for
{
for
{
<-
time
.
After
(
interval
)
<-
time
.
After
(
time
.
Duration
(
secs
)
*
time
.
Second
)
runtime
.
ReadMemStats
(
&
rtm
)
runtime
.
ReadMemStats
(
&
rtm
)
m
.
NumGoroutine
=
runtime
.
NumGoroutine
()
mem
:=
((
rtm
.
HeapIdle
-
rtm
.
HeapReleased
)
+
(
rtm
.
Alloc
+
rtm
.
HeapInuse
))
/
1e6
memMax
=
max
(
memMax
,
mem
)
m
.
Alloc
=
rtm
.
Alloc
/
1e6
m
.
Sys
=
rtm
.
Sys
/
1e6
m
.
LiveObjects
=
rtm
.
Mallocs
-
rtm
.
Frees
m
.
NumGC
=
rtm
.
NumGC
fmt
.
Println
(
zjson
.
MustString
(
m
))
fmt
.
Printf
(
"Z_DEBUG: MEM: %v; MEM_MAX: %v; OBJ: %v, GO: %v, GC: %v
\n
"
,
mem
,
memMax
,
(
rtm
.
Mallocs
-
rtm
.
Frees
)
/
1e3
,
runtime
.
NumGoroutine
(),
rtm
.
NumGC
,
)
}
}
}()
}()
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets