Skip to content

Commit 0096034

Browse files
committed
Add memory info to debug flag
1 parent 87c86f4 commit 0096034

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

app/states/player.go

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package states
22

33
import (
44
"fmt"
5+
"github.com/dustin/go-humanize"
56
"github.com/go-gl/mathgl/mgl32"
67
"github.com/wieku/danser-go/app/audio"
78
"github.com/wieku/danser-go/app/beatmap"
@@ -993,36 +994,50 @@ func (player *Player) drawDebug() {
993994

994995
var queue []tx
995996

996-
drawWithBackground := func(pos float64, text string) {
997+
pos := 3.0
998+
999+
drawWithBackground := func(text string) {
9971000
width := player.font.GetWidthMonospaced(size, text)
9981001
player.batch.DrawStObject(vector.NewVec2d(0, (size+padDown)*pos), vector.CentreLeft, vector.NewVec2d(width, size+padDown), false, false, 0, color2.NewLA(0, 0.8), false, graphics.Pixel.GetRegion())
9991002

10001003
queue = append(queue, tx{pos, text})
1004+
pos++
10011005
}
10021006

1003-
drawWithBackground(3, fmt.Sprintf("VSync: %t", settings.Graphics.VSync))
1004-
drawWithBackground(4, fmt.Sprintf("Blur: %t", settings.Playfield.Background.Blur.Enabled))
1005-
drawWithBackground(5, fmt.Sprintf("Bloom: %t", settings.Playfield.Bloom.Enabled))
1007+
drawWithBackground(fmt.Sprintf("VSync: %t", settings.Graphics.VSync))
1008+
drawWithBackground(fmt.Sprintf("Blur: %t", settings.Playfield.Background.Blur.Enabled))
1009+
drawWithBackground(fmt.Sprintf("Bloom: %t", settings.Playfield.Bloom.Enabled))
10061010

10071011
msaa := "OFF"
10081012
if settings.Graphics.MSAA > 0 {
10091013
msaa = strconv.Itoa(int(settings.Graphics.MSAA)) + "x"
10101014
}
10111015

1012-
drawWithBackground(6, fmt.Sprintf("MSAA: %s", msaa))
1016+
drawWithBackground(fmt.Sprintf("MSAA: %s", msaa))
10131017

1014-
drawWithBackground(7, fmt.Sprintf("FBO Binds: %d", statistic.GetPrevious(statistic.FBOBinds)))
1015-
drawWithBackground(8, fmt.Sprintf("VAO Binds: %d", statistic.GetPrevious(statistic.VAOBinds)))
1016-
drawWithBackground(9, fmt.Sprintf("VBO Binds: %d", statistic.GetPrevious(statistic.VBOBinds)))
1017-
drawWithBackground(10, fmt.Sprintf("Vertex Upload: %.2fk", float64(statistic.GetPrevious(statistic.VertexUpload))/1000))
1018-
drawWithBackground(11, fmt.Sprintf("Vertices Drawn: %.2fk", float64(statistic.GetPrevious(statistic.VerticesDrawn))/1000))
1019-
drawWithBackground(12, fmt.Sprintf("Draw Calls: %d", statistic.GetPrevious(statistic.DrawCalls)))
1020-
drawWithBackground(13, fmt.Sprintf("Sprites Drawn: %d", statistic.GetPrevious(statistic.SpritesDrawn)))
1018+
drawWithBackground(fmt.Sprintf("FBO Binds: %d", statistic.GetPrevious(statistic.FBOBinds)))
1019+
drawWithBackground(fmt.Sprintf("VAO Binds: %d", statistic.GetPrevious(statistic.VAOBinds)))
1020+
drawWithBackground(fmt.Sprintf("VBO Binds: %d", statistic.GetPrevious(statistic.VBOBinds)))
1021+
drawWithBackground(fmt.Sprintf("Vertex Upload: %.2fk", float64(statistic.GetPrevious(statistic.VertexUpload))/1000))
1022+
drawWithBackground(fmt.Sprintf("Vertices Drawn: %.2fk", float64(statistic.GetPrevious(statistic.VerticesDrawn))/1000))
1023+
drawWithBackground(fmt.Sprintf("Draw Calls: %d", statistic.GetPrevious(statistic.DrawCalls)))
1024+
drawWithBackground(fmt.Sprintf("Sprites Drawn: %d", statistic.GetPrevious(statistic.SpritesDrawn)))
10211025

10221026
if storyboard := player.background.GetStoryboard(); storyboard != nil {
1023-
drawWithBackground(14, fmt.Sprintf("SB sprites: %d", player.storyboardDrawn))
1027+
drawWithBackground(fmt.Sprintf("SB sprites: %d", player.storyboardDrawn))
10241028
}
10251029

1030+
pos++
1031+
drawWithBackground("Memory:")
1032+
1033+
var m runtime.MemStats
1034+
runtime.ReadMemStats(&m)
1035+
1036+
drawWithBackground(fmt.Sprintf("Allocated: %s", humanize.Bytes(m.Alloc)))
1037+
drawWithBackground(fmt.Sprintf("System: %s", humanize.Bytes(m.Sys)))
1038+
drawWithBackground(fmt.Sprintf("GC Runs: %d", m.NumGC))
1039+
drawWithBackground(fmt.Sprintf("GC Time: %.3fms", float64(m.PauseTotalNs)/1000000))
1040+
10261041
player.batch.ResetTransform()
10271042

10281043
for _, t := range queue {

0 commit comments

Comments
 (0)