From 93430cd5f43c4e871ee3e814bc71f7101528cc6d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 Nov 2023 22:49:20 +0530 Subject: [PATCH] Images benchmark should not measure speed of zlib --- tools/cmd/benchmark/main.go | 12 ++++++++---- tools/tui/graphics/command.go | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/cmd/benchmark/main.go b/tools/cmd/benchmark/main.go index 93436b06a..f0804bece 100644 --- a/tools/cmd/benchmark/main.go +++ b/tools/cmd/benchmark/main.go @@ -170,14 +170,18 @@ func images() (r result, err error) { g := graphics.GraphicsCommand{} g.SetImageId(12345) g.SetQuiet(graphics.GRT_quiet_silent) - g.SetAction(graphics.GRT_action_query) + g.SetAction(graphics.GRT_action_transmit) g.SetFormat(graphics.GRT_format_rgba) - const dim = 2048 + const dim = 1024 g.SetDataWidth(dim) g.SetDataHeight(dim) + g.DisableCompression = true // dont want to measure the speed of zlib b := strings.Builder{} - b.Grow(4*dim*dim + 256) + b.Grow(8 * dim * dim) _ = g.WriteWithPayloadTo(&b, make([]byte, 4*dim*dim)) + g.SetAction(graphics.GRT_action_delete) + g.SetDelete(graphics.GRT_free_by_id) + _ = g.WriteWithPayloadTo(&b, nil) data := b.String() duration, data_sz, err := benchmark_data(data, default_benchmark_options()) if err != nil { @@ -277,7 +281,7 @@ func main(args []string) (err error) { fmt.Print(reset) fmt.Println( - "These results measure the time it takes the terminal to fully parse all the data sent to it. Some terminals will not render all the data, skipping frames, thereby \"cheating\" in their results. kitty does render all data.") + "These results measure the time it takes the terminal to fully parse all the data sent to it. Note that not all data transmitted will be displayed as input parsing is typically asynchronous with rendering in high performance terminals.") fmt.Println() fmt.Println("Results:") mlen := 10 diff --git a/tools/tui/graphics/command.go b/tools/tui/graphics/command.go index c2df9a9b2..71fff5efb 100644 --- a/tools/tui/graphics/command.go +++ b/tools/tui/graphics/command.go @@ -145,6 +145,7 @@ type GraphicsCommand struct { z int32 + DisableCompression bool WrapPrefix, WrapSuffix string EncodeSerializedDataFunc func(string) string @@ -271,7 +272,7 @@ func (self *GraphicsCommand) WriteWithPayloadTo(o io.StringWriter, payload []byt return self.serialize_to(o, base64.RawStdEncoding.EncodeToString(payload)) } gc := *self - if self.Format() != GRT_format_png { + if !self.DisableCompression && self.Format() != GRT_format_png { compressed := compress_with_zlib(payload) if len(compressed) < len(payload) { gc.SetCompression(GRT_compression_zlib)