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

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit 523aae6f222a5904f33fd26c334a2f97bea6382d
Author: Boris Faure <[email protected]>
AuthorDate: Wed Nov 11 19:26:39 2026 +0000

    tests/bench: add an insert-mode corpus
    
    Under IRM every character written shifts the rest of its row, so typed
    text and REP cost a row shift per cell, and DECBI goes through the same
    path once per row. None of the corpora turns IRM on, so that shift had
    no benchmark: the fuzzers found inputs spending seconds in it.
    
    The corpus types words and REPs in insert mode, as a terminfo with smir
    makes curses do, with DCH, DECBI and DECFI now and then.
---
 tests/bench/gen_corpus.py | 34 +++++++++++++++++++++++++++++++++-
 tests/meson.build         |  3 ++-
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/tests/bench/gen_corpus.py b/tests/bench/gen_corpus.py
index c013569d..97da9370 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.
 
-Ten workloads, chosen so that a change to one part of the intake path shows up
+Eleven 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
@@ -22,6 +22,9 @@ in one column rather than being averaged away:
                Exercises the rectangle and screen fills.
   insert       ICH (CSI @) on a row, as editors open room for typed text, and
                DECIC (CSI ' }) now and then. Exercises the in-row shifts.
+  insert-mode  words and REPs typed under IRM (CSI 4 h), as when terminfo
+               has smir, with DCH and DECBI/DECFI now and then. Exercises
+               the row shift every character pays in insert mode.
   long-lines   lines kilobytes long, as minified JSON or one-line logs, with
                an accented word now and then. Exercises the ASCII runs that
                follow a non-ASCII character within one read.
@@ -240,6 +243,34 @@ def gen_insert(target):
     return bytes(out[:cut])
 
 
+def gen_insert_mode(target):
+    """Cursor moves, then a word or a REP typed in insert mode."""
+    rng = _rng("insert-mode")
+    out = bytearray(b"\033[4h")
+    cut = len(out)
+    while len(out) < target:
+        r = rng.random()
+        if r < 0.05:
+            seq = "\033[%d;1H\0336" % rng.randint(1, 24)
+        elif r < 0.10:
+            seq = "\033[%d;80H\0339" % rng.randint(1, 24)
+        elif r < 0.20:
+            seq = "\033[%d;%dH\033[%dP" % (rng.randint(1, 24), rng.randint(1, 80),
+                                           rng.randint(1, 80))
+        elif r < 0.40:
+            seq = "\033[%d;%dH%s\033[%db" % (rng.randint(1, 24), rng.randint(1, 40),
+                                             rng.choice("-=_.# "),
+                                             rng.randint(1, 79))
+        else:
+            seq = "\033[%d;%dH%s " % (rng.randint(1, 24), rng.randint(1, 80),
+                                     rng.choice(WORDS))
+        out += seq.encode("ascii")
+        # Whole sequences only, as in gen_sgr.
+        if len(out) <= target:
+            cut = len(out)
+    return bytes(out[:cut]) + b"\033[4l"
+
+
 def gen_long_lines(target):
     """Lines of 4 to 16 KiB of words, about one in 200 of them accented."""
     rng = _rng("long-lines")
@@ -275,6 +306,7 @@ GENERATORS = {
     "fill": gen_fill,
     "hyperlink": gen_hyperlink,
     "insert": gen_insert,
+    "insert-mode": gen_insert_mode,
     "long-lines": gen_long_lines,
     "plain-ascii": gen_plain_ascii,
     "rep": gen_rep,
diff --git a/tests/meson.build b/tests/meson.build
index df127982..a4ae5e5b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -99,7 +99,7 @@ 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', 'long-lines', 'plain-ascii', 'rep', 'scroll', 'sgr', 'strings', 'unicode'],
+      output: ['fill', 'hyperlink', 'insert', 'insert-mode', 'long-lines', 'plain-ascii', 'rep', 'scroll', 'sgr', 'strings', 'unicode'],
       command: [python3,
                 meson.current_source_dir() / 'bench' / 'gen_corpus.py',
                 '@OUTDIR@'],
@@ -112,6 +112,7 @@ if benchmarks
                    bench_corpus_dir / 'fill',
                    bench_corpus_dir / 'hyperlink',
                    bench_corpus_dir / 'insert',
+                   bench_corpus_dir / 'insert-mode',
                    bench_corpus_dir / 'long-lines',
                    bench_corpus_dir / 'plain-ascii',
                    bench_corpus_dir / 'rep',

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

Reply via email to