From ad7f671a7bdfe2cf92a180bab837e7d63672519a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 10 Nov 2023 12:21:49 +0530 Subject: [PATCH] Add a long escape code benchmark --- tools/cmd/benchmark/main.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/cmd/benchmark/main.go b/tools/cmd/benchmark/main.go index bb0491db8..fa6ea8cfd 100644 --- a/tools/cmd/benchmark/main.go +++ b/tools/cmd/benchmark/main.go @@ -160,6 +160,17 @@ func images() (r result, err error) { return result{"Images", len(data), duration}, nil } +func long_escape_codes() (r result, err error) { + data := random_string_of_bytes(8192, ascii_printable) + // OSC 6 is document reporting which kitty ignores after parsing + data = strings.Repeat("\x1b]6;"+data+"\x07", 1024) + duration, err := benchmark_data(data, default_benchmark_options()) + if err != nil { + return result{}, err + } + return result{"Images", len(data), duration}, nil +} + var divs = []time.Duration{ time.Duration(1), time.Duration(10), time.Duration(100), time.Duration(1000)} @@ -177,14 +188,14 @@ func round(d time.Duration, digits int) time.Duration { func present_result(r result, col_width int) { rate := float64(r.data_sz) / r.duration.Seconds() - rate /= 1024 * 1024 + rate /= 1024. * 1024. f := fmt.Sprintf("%%-%ds", col_width) fmt.Printf(" "+f+" : %-10v @ \x1b[32m%.1f\x1b[m MB/s\n", r.desc, round(r.duration, 2), rate) } func all_benchamrks() []string { return []string{ - "ascii", "csi", "images", + "ascii", "csi", "images", "long_escape_codes", } } @@ -208,6 +219,13 @@ func main(args []string) (err error) { results = append(results, r) } + if slices.Index(args, "long_escape_codes") >= 0 { + if r, err = long_escape_codes(); err != nil { + return err + } + results = append(results, r) + } + if slices.Index(args, "images") >= 0 { if r, err = images(); err != nil { return err