Skip to content
GitLab
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
7378a986
Commit
7378a986
authored
Nov 17, 2023
by
Vladimir Barsukov
Browse files
zdebug
parent
e53f6d70
Changes
2
Hide whitespace changes
Inline
Side-by-side
zdebug/zdebug.go
0 → 100644
View file @
7378a986
package
zdebug
import
(
"fmt"
"git.barsukov.pro/barsukov/zgo/zjson"
"runtime"
"time"
)
type
Monitor
struct
{
Alloc
,
TotalAlloc
,
Sys
,
LiveObjects
uint64
NumGC
uint32
NumGoroutine
int
}
func
NewMonitor
(
secs
int
)
{
go
func
()
{
var
m
Monitor
var
rtm
runtime
.
MemStats
var
interval
=
time
.
Duration
(
secs
)
*
time
.
Second
for
{
<-
time
.
After
(
interval
)
runtime
.
ReadMemStats
(
&
rtm
)
m
.
NumGoroutine
=
runtime
.
NumGoroutine
()
m
.
Alloc
=
rtm
.
Alloc
/
1e6
m
.
TotalAlloc
=
rtm
.
TotalAlloc
/
1e6
m
.
Sys
=
rtm
.
Sys
/
1e6
m
.
LiveObjects
=
rtm
.
Mallocs
-
rtm
.
Frees
m
.
NumGC
=
rtm
.
NumGC
fmt
.
Println
(
zjson
.
MustString
(
m
))
}
}()
}
zgo.go
View file @
7378a986
...
...
@@ -5,6 +5,7 @@ import (
_
"git.barsukov.pro/barsukov/zgo/zcache"
_
"git.barsukov.pro/barsukov/zgo/zcron"
_
"git.barsukov.pro/barsukov/zgo/zdb"
_
"git.barsukov.pro/barsukov/zgo/zdebug"
_
"git.barsukov.pro/barsukov/zgo/zgin"
_
"git.barsukov.pro/barsukov/zgo/zjson"
_
"git.barsukov.pro/barsukov/zgo/zq"
...
...
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