From 32f086242ca94b257820d08c8daafb9b855ac698 Mon Sep 17 00:00:00 2001 From: bloeys Date: Sun, 25 Sep 2022 05:03:57 +0400 Subject: [PATCH] Continue SGR parse even if reset is found+Heap pprof profile --- .gitignore | 2 +- ansi/ansi.go | 3 ++- main.go | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0c0f96a..952ddd8 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ # Custom *.png -*.cpu +*.pprof 1gb.txt 1gb.bin diff --git a/ansi/ansi.go b/ansi/ansi.go index 70a67c4..21d6ffa 100755 --- a/ansi/ansi.go +++ b/ansi/ansi.go @@ -273,6 +273,7 @@ func InfoFromAnsiCode(code []byte) (info AnsiCodeInfo) { func ParseSGRArgs(args []byte) (payload []AnsiCodeInfoPayload) { + // @PERF: Too many allocations here, once per code :/ payload = make([]AnsiCodeInfoPayload, 0, 1) // @TODO should we trim spaces? @@ -283,7 +284,7 @@ func ParseSGRArgs(args []byte) (payload []AnsiCodeInfoPayload) { payload = append(payload, AnsiCodeInfoPayload{ Type: AnsiCodePayloadType_Reset, }) - break + continue } // @TODO We can't use this setup of one info field because one ansi code can have many settings. diff --git a/main.go b/main.go index 3322bfd..06e0fdb 100755 --- a/main.go +++ b/main.go @@ -180,7 +180,7 @@ func main() { p.win.SDLWin.GLSwap() if consts.Mode_Debug { - var pf, _ = os.Create("pprof.cpu") + var pf, _ = os.Create("cpu.pprof") defer pf.Close() pprof.StartCPUProfile(pf) } @@ -189,6 +189,10 @@ func main() { if consts.Mode_Debug { pprof.StopCPUProfile() + + var heapProfile, _ = os.Create("heap.pprof") + defer heapProfile.Close() + pprof.WriteHeapProfile(heapProfile) } }