mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 20:52:15 +08:00
chore: better memory fetching time
This commit is contained in:
parent
e4f762822a
commit
928dcf9af9
@ -61,6 +61,7 @@ func (m *Manager) Now() (up int64, down int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Memory() uint64 {
|
func (m *Manager) Memory() uint64 {
|
||||||
|
m.updateMemory()
|
||||||
return m.memory
|
return m.memory
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,16 +71,6 @@ func (m *Manager) Snapshot() *Snapshot {
|
|||||||
connections = append(connections, value.(tracker))
|
connections = append(connections, value.(tracker))
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
getMem := func() uint64 {
|
|
||||||
stat, err := m.process.MemoryInfo()
|
|
||||||
if err != nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return stat.RSS
|
|
||||||
}
|
|
||||||
m.memory = getMem()
|
|
||||||
|
|
||||||
return &Snapshot{
|
return &Snapshot{
|
||||||
UploadTotal: m.uploadTotal.Load(),
|
UploadTotal: m.uploadTotal.Load(),
|
||||||
DownloadTotal: m.downloadTotal.Load(),
|
DownloadTotal: m.downloadTotal.Load(),
|
||||||
@ -88,6 +79,14 @@ func (m *Manager) Snapshot() *Snapshot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Manager) updateMemory() {
|
||||||
|
stat, err := m.process.MemoryInfo()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.memory = stat.RSS
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Manager) ResetStatistic() {
|
func (m *Manager) ResetStatistic() {
|
||||||
m.uploadTemp.Store(0)
|
m.uploadTemp.Store(0)
|
||||||
m.uploadBlip.Store(0)
|
m.uploadBlip.Store(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user