diff options
Diffstat (limited to 'bench')
| -rw-r--r-- | bench/README.md | 31 | ||||
| -rw-r--r-- | bench/editor.py | 2 |
2 files changed, 17 insertions, 16 deletions
diff --git a/bench/README.md b/bench/README.md index 9621ba3..128748c 100644 --- a/bench/README.md +++ b/bench/README.md @@ -363,37 +363,38 @@ has no sub-second format. `BENCH_N` sets the number of starts, and ## The line editor -`EDIT=libedit` replaces the built-in editor with libedit, and the two -costs it changes are both in the interactive path, which `run.sh` and -`startup.sh` do not touch. `editor.py` measures them on a +The editor is built in, and `editor.py` is what made that decision easy. +It measures the two costs the off-the-shelf editor changed, both in the +interactive path that `run.sh` and `startup.sh` do not touch, on a pseudo-terminal: `BENCH_N` starts, each timed from just before the fork to the first byte of the prompt, then `BENCH_KEYS` keys typed one at a time, each timed from the write to its echo. ```sh -make EDIT=libedit LDLIBS=-ledit # writes ./zash, keep a copy -cp zash zash-libedit && make zash # the built-in one -python3 bench/editor.py ./zash ./zash-libedit +python3 bench/editor.py ./zash dash bash # any shells, it types at each ``` -Linux, both `-O3`, 20 and then 50 starts, keys medians of 200: +Linux, `-O3`, 20 and then 50 starts, keys medians of 200: | editor | start | one key | | --- | --- | --- | | built-in | 0.94-1.02 ms | 7.2-8.5 us | | libedit | 1.20-1.27 ms | 7.2-7.4 us | -libedit pays about a third of a millisecond more to get to the prompt: -three more shared libraries to load (libedit, ncurses, and the terminfo -entry it reads), `el_init()`, an `~/.editrc` attempt, and the copy of -the shell's history into libedit. Every key costs the same either way; -the round trip is the terminal driver and the scheduler, and the editor's -own work on a key is too small to see through that. +libedit, which zash could be built against (`make EDIT=libedit`) until it +was dropped, paid about a third of a millisecond more to get to the +prompt: three more shared libraries to load (libedit, ncurses, and the +terminfo entry it reads), `el_init()`, an `~/.editrc` attempt, and the +copy of the shell's history into libedit. Every key costs the same either +way; the round trip is the terminal driver and the scheduler, and the +editor's own work on a key is too small to see through that. -So the built-in editor wins a start that never edits, which is the case +So the built-in editor wins the start that never edits, which is the case `make check` and a `#!` line are; for a session spent typing, the two are the same. Neither forks or execs per key, which is the cost that would -have mattered. +have mattered. DESIGN.md records the rest of the reason: FreeBSD and +NetBSD `sh` use libedit because it is in their base system, and z/OS has +no such thing. ## Address mode: 64-bit now diff --git a/bench/editor.py b/bench/editor.py index 6e99cdf..e6d3240 100644 --- a/bench/editor.py +++ b/bench/editor.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """What the line editor costs: start to first prompt, then one key. - bench/editor.py ./zash ./zash-libedit [more shells ...] + bench/editor.py ./zash dash bash [more shells ...] Each shell is started BENCH_N times (default 20) on a pseudo-terminal, the wall clock is read from just before the fork to the first byte of the |
