This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-11-parser-speedup
in repository terminology.

View the commit online.

commit 4e2221f7b3012cc356d5a890dcda272c93205331
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 22 13:43:47 2026 -0600

    tests/bench: add truecolor-cells and csi-motion corpora
    
    truecolor-cells is a frame stream with a truecolor foreground and
    background and a half block for every cell, and csi-motion is the
    cursor positioning, short text and basic SGR of a full-screen redraw.
    They give changes to the CSI and text paths a workload each, with
    csi-motion there to show that a gain is not specific to colour output.
    
    The other corpora are byte-identical to before.
---
 tests/bench/gen_corpus.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++-
 tests/meson.build         |  6 ++--
 2 files changed, 87 insertions(+), 3 deletions(-)

diff --git a/tests/bench/gen_corpus.py b/tests/bench/gen_corpus.py
index 42c98562..882109fd 100644
--- a/tests/bench/gen_corpus.py
+++ b/tests/bench/gen_corpus.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 """Generate deterministic benchmark corpora for tybench.
 
-Twelve workloads, chosen so that a change to one part of the intake path shows up
+Fourteen workloads, chosen so that a change to one part of the intake path shows up
 in one column rather than being averaged away:
 
   plain-ascii  long lines of printable ASCII, almost no escapes. The pure
@@ -35,6 +35,14 @@ in one column rather than being averaged away:
                  then a few of the opened lines redrawn, as editors and
                  pagers scroll under a status line. Exercises the
                  multi-line scroll of a region.
+  truecolor-cells  frames of an 80x24 text screen where every cell sets a
+                 truecolor foreground and background (CSI 38;2 and 48;2)
+                 and prints a half block, as animated terminal graphics
+                 do. Exercises the CSI colour path, one sequence for each
+                 few bytes of text.
+  csi-motion   cursor positioning, short text, erase in line and basic
+               SGR, as vim, tmux and htop redraw. A guard that a gain is
+               general rather than specific to colour output.
 
 Output is byte-identical across runs (fixed seed, no clock, no locale) so that
 numbers from different days are comparable.
@@ -330,7 +338,81 @@ def gen_scroll_region(target):
     return bytes(out[:cut]) + b"\033[r"
 
 
+def gen_truecolor_cells(target):
+    """Frames of 80x24 cells, each with a truecolor fg and bg and a half block."""
+    rng = _rng("truecolor-cells")
+    cols, rows = 80, 24
+    heat = [0] * (cols * (rows * 2 + 1))
+    for x in range(cols):
+        heat[(rows * 2) * cols + x] = 255
+    out = bytearray()
+    cut = 0
+    steps = 0
+    while len(out) < target:
+        # One step of the usual fire: each cell takes a decayed neighbour.
+        for y in range(rows * 2):
+            for x in range(cols):
+                src = "" + 1) * cols + (x + rng.randint(-1, 1)) % cols
+                heat[y * cols + x] = max(0, heat[src] - rng.randint(0, 2) * 8)
+        steps += 1
+        if steps < 60:
+            # Let the flames climb before the first frame is written.
+            continue
+        frame = ["\033[H"]
+        for y in range(rows):
+            for x in range(cols):
+                top, bottom = heat[2 * y * cols + x], heat[(2 * y + 1) * cols + x]
+                frame.append("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm\u2580"
+                             % (top, top * 3 // 4, top // 4,
+                                bottom, bottom * 3 // 4, bottom // 4))
+            frame.append("\033[0m\r\n" if y < rows - 1 else "\033[0m")
+        out += "".join(frame).encode("utf-8")
+        # Whole frames only, as in gen_sgr.
+        if len(out) <= target:
+            cut = len(out)
+    if cut == 0:
+        cut = len(out)
+    return bytes(out[:cut])
+
+
+def gen_csi_motion(target):
+    """Cursor moves, short text, EL and basic SGR, as a full-screen redraw."""
+    rng = _rng("csi-motion")
+    out = bytearray()
+    cut = 0
+    while len(out) < target:
+        r = rng.random()
+        move = "\033[%d;%dH" % (rng.randint(1, 24), rng.randint(1, 80))
+        if r < 0.30:
+            seq = move + rng.choice(WORDS) + " " + rng.choice(WORDS)
+        elif r < 0.50:
+            seq = move + "\033[%dm%s\033[m" % (rng.choice([1, 4, 7, 31, 32, 33, 36]),
+                                               rng.choice(WORDS))
+        elif r < 0.60:
+            seq = move + "\033[K" + rng.choice(WORDS)
+        elif r < 0.70:
+            seq = "\033[%dC%s" % (rng.randint(1, 20), rng.choice(WORDS))
+        elif r < 0.80:
+            seq = "\033[%dm\033[%dm%s\033[0m" % (rng.randint(30, 37),
+                                                 rng.randint(40, 47),
+                                                 rng.choice(WORDS))
+        elif r < 0.90:
+            seq = "\033[%dA\033[%dD%s" % (rng.randint(1, 5), rng.randint(1, 9),
+                                         rng.choice(WORDS))
+        else:
+            seq = move + "\033[38;5;%dm%s" % (rng.randint(0, 255), rng.choice(WORDS))
+        out += seq.encode("ascii")
+        # Whole sequences only, as in gen_sgr.
+        if len(out) <= target:
+            cut = len(out)
+    if cut == 0:
+        cut = len(out)
+    return bytes(out[:cut]) + b"\033[m"
+
+
 GENERATORS = {
+    "csi-motion": gen_csi_motion,
+    "truecolor-cells": gen_truecolor_cells,
     "fill": gen_fill,
     "hyperlink": gen_hyperlink,
     "insert": gen_insert,
diff --git a/tests/meson.build b/tests/meson.build
index 144246f0..dd47eb4f 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -128,13 +128,14 @@ if benchmarks
   # generator is deterministic so the bytes are reproducible. It writes to
   # @OUTDIR@ so that what it produces is what 'output' declares.
   bench_corpus = custom_target('bench-corpus',
-      output: ['fill', 'hyperlink', 'insert', 'insert-mode', 'long-lines', 'plain-ascii', 'rep', 'scroll', 'scroll-region', 'sgr', 'strings', 'unicode'],
+      output: ['csi-motion', 'fill', 'hyperlink', 'insert', 'insert-mode', 'long-lines', 'plain-ascii', 'rep', 'scroll', 'scroll-region', 'sgr', 'strings', 'truecolor-cells', 'unicode'],
       command: [python3,
                 meson.current_source_dir() / 'bench' / 'gen_corpus.py',
                 '@OUTDIR@'],
       build_by_default: false)
 
-  bench_corpora = [bench_corpus_dir / 'fill',
+  bench_corpora = [bench_corpus_dir / 'csi-motion',
+                   bench_corpus_dir / 'fill',
                    bench_corpus_dir / 'hyperlink',
                    bench_corpus_dir / 'insert',
                    bench_corpus_dir / 'insert-mode',
@@ -144,6 +145,7 @@ if benchmarks
                    bench_corpus_dir / 'scroll',
                    bench_corpus_dir / 'scroll-region',
                    bench_corpus_dir / 'sgr',
+                   bench_corpus_dir / 'truecolor-cells',
                    bench_corpus_dir / 'unicode']
 
   # Run with `meson test --benchmark`.

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to