mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 14:45:29 +00:00
benchmark kitten: Add scrollback and render benchmarks and --output
Replace the --with-scrollback and --render flags with two new benchmarks, scrollback and render, that use the ASCII text with the main screen and with rendering allowed, respectively. All other benchmarks use the alternate screen with rendering suppressed. Add an --output flag to also write the results to a file as JSON and list the available benchmarks with descriptions in the help text.
This commit is contained in:
parent
1231ecc534
commit
40d41ca4f5
3 changed files with 165 additions and 127 deletions
30
benchmark.py
30
benchmark.py
|
|
@ -25,7 +25,19 @@ from kitty.fast_data_types import ChildMonitor, Region, Screen, safe_pipe, set_o
|
|||
from kitty.utils import read_screen_size
|
||||
|
||||
BENCHMARK_WINDOW_ID = 1
|
||||
PARSING_BENCHMARKS = ('ascii', 'unicode', 'unique_unicode', 'csi', 'images', 'long_escape_codes', 'truecolor_text', 'palette16_text', 'halfblocks')
|
||||
PARSING_BENCHMARKS = (
|
||||
'ascii',
|
||||
'unicode',
|
||||
'scrollback',
|
||||
'render',
|
||||
'unique_unicode',
|
||||
'csi',
|
||||
'images',
|
||||
'long_escape_codes',
|
||||
'truecolor_text',
|
||||
'palette16_text',
|
||||
'halfblocks',
|
||||
)
|
||||
ALL_BENCHMARKS = PARSING_BENCHMARKS + ('tab_bar',)
|
||||
TAB_BAR_STYLES = ('fade', 'separator', 'powerline', 'slant')
|
||||
TAB_BAR_NUM_TABS = (10, 50, 200)
|
||||
|
|
@ -91,7 +103,6 @@ def run_perf_reports(perf_exe: str) -> None:
|
|||
|
||||
def run_parsing_benchmark(
|
||||
benchmarks: tuple[str, ...] = PARSING_BENCHMARKS,
|
||||
with_scrollback: bool = True,
|
||||
cell_width: int = 10,
|
||||
cell_height: int = 20,
|
||||
scrollback: int = 20000,
|
||||
|
|
@ -105,11 +116,7 @@ def run_parsing_benchmark(
|
|||
columns, rows = 80, 25
|
||||
child_pid, master_fd = fork()
|
||||
is_child = child_pid == CHILD
|
||||
# we add render as we aren't rendering anyway and it means the synchronized
|
||||
# escape codes are no longer needed.
|
||||
argv = [kitten_exe(), '__benchmark__', '--render']
|
||||
if with_scrollback:
|
||||
argv.append('--with-scrollback')
|
||||
argv = [kitten_exe(), '__benchmark__']
|
||||
if repetitions is not None:
|
||||
argv.extend(['--repetitions', str(repetitions)])
|
||||
argv.extend(benchmarks)
|
||||
|
|
@ -280,13 +287,6 @@ def main() -> None:
|
|||
metavar='BENCHMARK',
|
||||
help=f'Benchmarks to run (default: all). Choose from: {", ".join(ALL_BENCHMARKS)}',
|
||||
)
|
||||
p.add_argument(
|
||||
'--with-scrollback',
|
||||
dest='with_scrollback',
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=True,
|
||||
help='Use the main screen instead of the alt screen so scrollback speed is also tested (default: enabled)',
|
||||
)
|
||||
p.add_argument(
|
||||
'--perf',
|
||||
action='store_true',
|
||||
|
|
@ -328,7 +328,7 @@ def main() -> None:
|
|||
|
||||
benchmarks = tuple(args.benchmarks) if args.benchmarks else ALL_BENCHMARKS
|
||||
if parsing_benchmarks := tuple(b for b in benchmarks if b in PARSING_BENCHMARKS):
|
||||
run_parsing_benchmark(benchmarks=parsing_benchmarks, with_scrollback=args.with_scrollback, repetitions=args.repetitions)
|
||||
run_parsing_benchmark(benchmarks=parsing_benchmarks, repetitions=args.repetitions)
|
||||
if 'tab_bar' in benchmarks:
|
||||
run_tab_bar_benchmark(compare_with=args.compare_with, repetitions=args.repetitions)
|
||||
|
||||
|
|
|
|||
|
|
@ -107,11 +107,11 @@ ASCII only text.
|
|||
|
||||
.. note::
|
||||
|
||||
By default, the benchmark kitten suppresses actual rendering, to better
|
||||
focus on parser speed, you can pass it the ``--render`` flag to not suppress
|
||||
rendering. However, modern terminals typically render asynchronously,
|
||||
therefore the numbers are not really useful for comparison, as it is just a
|
||||
game about how much input to *batch* before rendering the next frame.
|
||||
The benchmark kitten suppresses actual rendering, to better focus on parser
|
||||
speed, except in its ``render`` benchmark. However, modern terminals
|
||||
typically render asynchronously, therefore the numbers from that benchmark
|
||||
are not really useful for comparison, as it is just a game about how much
|
||||
input to *batch* before rendering the next frame.
|
||||
However, even with rendering enabled kitty is still faster than all the
|
||||
rest. For brevity those numbers are not included.
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ package benchmark
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand/v2"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -24,9 +26,22 @@ import (
|
|||
var _ = fmt.Print
|
||||
|
||||
type Options struct {
|
||||
Repetitions int
|
||||
WithScrollback bool
|
||||
Render bool
|
||||
Repetitions int
|
||||
Output string
|
||||
}
|
||||
|
||||
// How a benchmark is run
|
||||
type run_settings struct {
|
||||
repetitions int
|
||||
// Use the main screen instead of the alternate screen, so that lines
|
||||
// scrolled off the screen go into the scrollback
|
||||
main_screen bool
|
||||
// Allow the terminal to render while the data is being sent
|
||||
render bool
|
||||
}
|
||||
|
||||
func default_settings() run_settings {
|
||||
return run_settings{repetitions: opts.Repetitions}
|
||||
}
|
||||
|
||||
const reset = "\x1b]\x1b\\\x1bc"
|
||||
|
|
@ -45,7 +60,7 @@ const misc_unicode = "‘’“”‹›«»‚„ 😀😛😇😈😉😍😎
|
|||
|
||||
var opts Options
|
||||
|
||||
func benchmark_data(description string, data string, opts Options) (duration time.Duration, sent_data_size int, reps int, err error) {
|
||||
func benchmark_data(description string, data string, settings run_settings) (duration time.Duration, sent_data_size int, reps int, err error) {
|
||||
term, err := tty.OpenControllingTerm(tty.SetRaw)
|
||||
if err != nil {
|
||||
return 0, 0, 0, err
|
||||
|
|
@ -54,7 +69,7 @@ func benchmark_data(description string, data string, opts Options) (duration tim
|
|||
write_with_retry := func(data string) (err error) {
|
||||
return term.WriteAllString(data)
|
||||
}
|
||||
state := loop.TerminalStateOptions{Alternate_screen: !opts.WithScrollback}
|
||||
state := loop.TerminalStateOptions{Alternate_screen: !settings.main_screen}
|
||||
if err = write_with_retry(state.SetStateEscapeCodes() + loop.DECTCEM.EscapeCodeToReset()); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -65,7 +80,7 @@ func benchmark_data(description string, data string, opts Options) (duration tim
|
|||
desc := clear_screen + "Running: " + description + "\r\n"
|
||||
const pause_rendering = "\x1b[?2026h"
|
||||
const resume_rendering = "\x1b[?2026l"
|
||||
if !opts.Render {
|
||||
if !settings.render {
|
||||
if err = write_with_retry(desc + pause_rendering); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -73,10 +88,10 @@ func benchmark_data(description string, data string, opts Options) (duration tim
|
|||
|
||||
start := time.Now()
|
||||
end_of_loop_reset := desc
|
||||
if !opts.Render {
|
||||
if !settings.render {
|
||||
end_of_loop_reset += resume_rendering + pause_rendering
|
||||
}
|
||||
for reps < opts.Repetitions {
|
||||
for reps < settings.repetitions {
|
||||
if err = write_with_retry(data); err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -87,7 +102,7 @@ func benchmark_data(description string, data string, opts Options) (duration tim
|
|||
}
|
||||
}
|
||||
finalize := clear_screen + "Waiting for response indicating parsing finished\r\n"
|
||||
if !opts.Render {
|
||||
if !settings.render {
|
||||
finalize += resume_rendering
|
||||
}
|
||||
finalize += "\x1b[6n" + strings.Repeat("\x1b[5n", count)
|
||||
|
|
@ -121,7 +136,7 @@ func random_string_of_bytes(n int, alphabet string) string {
|
|||
}
|
||||
|
||||
type result struct {
|
||||
desc string
|
||||
name, desc string
|
||||
data_sz int
|
||||
duration time.Duration
|
||||
repetitions int
|
||||
|
|
@ -179,12 +194,12 @@ func text_with_layout(next func(remaining int) (string, int)) (text string, cell
|
|||
return b.String(), cells
|
||||
}
|
||||
|
||||
func text_benchmark(desc string, data string, cells int) (r result, err error) {
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data, opts)
|
||||
func text_benchmark(desc string, data string, cells int, settings run_settings) (r result, err error) {
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data, settings)
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, cells}, nil
|
||||
return result{"", desc, data_sz, duration, reps, cells}, nil
|
||||
}
|
||||
|
||||
func ascii_text() (string, int) {
|
||||
|
|
@ -196,7 +211,21 @@ func ascii_text() (string, int) {
|
|||
|
||||
func simple_ascii() (r result, err error) {
|
||||
data, cells := ascii_text()
|
||||
return text_benchmark("ASCII text", data, cells)
|
||||
return text_benchmark("ASCII text", data, cells, default_settings())
|
||||
}
|
||||
|
||||
func ascii_with_scrollback() (r result, err error) {
|
||||
data, cells := ascii_text()
|
||||
s := default_settings()
|
||||
s.main_screen = true
|
||||
return text_benchmark("ASCII text with scrollback", data, cells, s)
|
||||
}
|
||||
|
||||
func ascii_with_rendering() (r result, err error) {
|
||||
data, cells := ascii_text()
|
||||
s := default_settings()
|
||||
s.render = true
|
||||
return text_benchmark("ASCII text with rendering", data, cells, s)
|
||||
}
|
||||
|
||||
func unicode_text() (string, int) {
|
||||
|
|
@ -226,7 +255,7 @@ func unicode_text() (string, int) {
|
|||
|
||||
func unicode() (r result, err error) {
|
||||
data, cells := unicode_text()
|
||||
return text_benchmark("Unicode text", data, cells)
|
||||
return text_benchmark("Unicode text", data, cells, default_settings())
|
||||
}
|
||||
|
||||
func unique_unicode() (r result, err error) {
|
||||
|
|
@ -243,11 +272,11 @@ func unique_unicode() (r result, err error) {
|
|||
}
|
||||
}
|
||||
const desc = "Unique multi-codepoint Unicode cells"
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data.String(), opts)
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data.String(), default_settings())
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, 0}, nil
|
||||
return result{"", desc, data_sz, duration, reps, 0}, nil
|
||||
}
|
||||
|
||||
func ascii_with_csi() (r result, err error) {
|
||||
|
|
@ -276,11 +305,11 @@ func ascii_with_csi() (r result, err error) {
|
|||
}
|
||||
out = append(out, "\x1b[m"...)
|
||||
const desc = "CSI codes with few chars"
|
||||
duration, data_sz, reps, err := benchmark_data(desc, utils.UnsafeBytesToString(out), opts)
|
||||
duration, data_sz, reps, err := benchmark_data(desc, utils.UnsafeBytesToString(out), default_settings())
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, 0}, nil
|
||||
return result{"", desc, data_sz, duration, reps, 0}, nil
|
||||
}
|
||||
|
||||
type rgb struct{ r, g, b int }
|
||||
|
|
@ -299,11 +328,11 @@ func colored_text_benchmark(desc string, next_color func() rgb) (r result, err e
|
|||
fmt.Fprintf(&b, "\x1b[38;2;%d;%d;%dm%c", c.r, c.g, c.b, alphabet[rand.IntN(len(alphabet))])
|
||||
}
|
||||
b.WriteString("\x1b[m")
|
||||
duration, data_sz, reps, err := benchmark_data(desc, b.String(), opts)
|
||||
duration, data_sz, reps, err := benchmark_data(desc, b.String(), default_settings())
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, 0}, nil
|
||||
return result{"", desc, data_sz, duration, reps, 0}, nil
|
||||
}
|
||||
|
||||
func truecolor_text() (r result, err error) {
|
||||
|
|
@ -335,11 +364,11 @@ func halfblocks() (r result, err error) {
|
|||
b.WriteString("\x1b[m\r\n")
|
||||
}
|
||||
const desc = "Truecolor half blocks"
|
||||
duration, data_sz, reps, err := benchmark_data(desc, b.String(), opts)
|
||||
duration, data_sz, reps, err := benchmark_data(desc, b.String(), default_settings())
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, 0}, nil
|
||||
return result{"", desc, data_sz, duration, reps, 0}, nil
|
||||
}
|
||||
|
||||
func images() (r result, err error) {
|
||||
|
|
@ -360,11 +389,11 @@ func images() (r result, err error) {
|
|||
_ = g.WriteWithPayloadTo(&b, nil)
|
||||
data := b.String()
|
||||
const desc = "Images"
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data, opts)
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data, default_settings())
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, 0}, nil
|
||||
return result{"", desc, data_sz, duration, reps, 0}, nil
|
||||
}
|
||||
|
||||
func long_escape_codes() (r result, err error) {
|
||||
|
|
@ -372,11 +401,11 @@ func long_escape_codes() (r result, err error) {
|
|||
// OSC 6 is document reporting or XTerm special color which kitty ignores after parsing
|
||||
data = strings.Repeat("\x1b]6;"+data+"\x07", 1024)
|
||||
const desc = "Long escape codes"
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data, opts)
|
||||
duration, data_sz, reps, err := benchmark_data(desc, data, default_settings())
|
||||
if err != nil {
|
||||
return result{}, err
|
||||
}
|
||||
return result{desc, data_sz, duration, reps, 0}, nil
|
||||
return result{"", desc, data_sz, duration, reps, 0}, nil
|
||||
}
|
||||
|
||||
var divs = []time.Duration{
|
||||
|
|
@ -405,12 +434,34 @@ func present_result(r result, col_width int) {
|
|||
fmt.Printf(" "+f+" : %-10v @ \x1b[32m%-7.1f\x1b[m MB/s%s\n", r.desc, round(r.duration, 2), rate, cells)
|
||||
}
|
||||
|
||||
func all_benchamrks() []string {
|
||||
return []string{
|
||||
"ascii", "unicode", "unique_unicode", "csi", "images", "long_escape_codes", "truecolor_text", "palette16_text", "halfblocks",
|
||||
type benchmark struct {
|
||||
name, help string
|
||||
run func() (result, error)
|
||||
}
|
||||
|
||||
func all_benchmarks() []benchmark {
|
||||
return []benchmark{
|
||||
{"ascii", "lines of ASCII text", simple_ascii},
|
||||
{"unicode", "lines of non-ASCII text, the same lines, in cells, as ascii", unicode},
|
||||
{"scrollback", "the ascii text, on the main screen so lines scrolled off the screen go into the scrollback", ascii_with_scrollback},
|
||||
{"render", "the ascii text, with rendering allowed while it is processed", ascii_with_rendering},
|
||||
{"unique_unicode", "cells with many distinct multi-codepoint graphemes", unique_unicode},
|
||||
{"csi", "ASCII text mixed with many CSI escape codes", ascii_with_csi},
|
||||
{"long_escape_codes", "long OSC escape codes", long_escape_codes},
|
||||
{"truecolor_text", "text with a random 24-bit color for every char", truecolor_text},
|
||||
{"palette16_text", "text with one of 16 colors for every char", palette16_text},
|
||||
{"halfblocks", "half block characters with random 24-bit foreground and background colors", halfblocks},
|
||||
{"images", "images sent using the kitty graphics protocol", images},
|
||||
}
|
||||
}
|
||||
|
||||
func benchmark_names() (ans []string) {
|
||||
for _, b := range all_benchmarks() {
|
||||
ans = append(ans, b.name)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func warmup_data() string {
|
||||
num_colors := 1000 + rand.IntN(1001)
|
||||
type rgb struct{ r, g, b uint8 }
|
||||
|
|
@ -434,89 +485,37 @@ func warmup_data() string {
|
|||
|
||||
func main(args []string) (err error) {
|
||||
if len(args) == 0 {
|
||||
args = all_benchamrks()
|
||||
args = benchmark_names()
|
||||
}
|
||||
for _, a := range args {
|
||||
if slices.Index(benchmark_names(), a) < 0 {
|
||||
return fmt.Errorf("Unknown benchmark: %s, choose from: %s", a, strings.Join(benchmark_names(), ", "))
|
||||
}
|
||||
}
|
||||
var results []result
|
||||
var r result
|
||||
// First warm up the terminal by getting it to render all chars so that font rendering
|
||||
// time is not polluting the benchmarks.
|
||||
w := Options{Repetitions: 1}
|
||||
if _, _, _, err = benchmark_data("Warmup", warmup_data(), w); err != nil {
|
||||
if _, _, _, err = benchmark_data("Warmup", warmup_data(), run_settings{repetitions: 1}); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(time.Second / 2)
|
||||
|
||||
if slices.Index(args, "ascii") >= 0 {
|
||||
if r, err = simple_ascii(); err != nil {
|
||||
return err
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
if slices.Index(args, "unicode") >= 0 {
|
||||
if r, err = unicode(); err != nil {
|
||||
return err
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
if slices.Index(args, "unique_unicode") >= 0 {
|
||||
if r, err = unique_unicode(); err != nil {
|
||||
return err
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
if slices.Index(args, "csi") >= 0 {
|
||||
if r, err = ascii_with_csi(); err != nil {
|
||||
return err
|
||||
}
|
||||
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, "truecolor_text") >= 0 {
|
||||
if r, err = truecolor_text(); err != nil {
|
||||
return err
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
if slices.Index(args, "palette16_text") >= 0 {
|
||||
if r, err = palette16_text(); err != nil {
|
||||
return err
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
if slices.Index(args, "halfblocks") >= 0 {
|
||||
if r, err = halfblocks(); err != nil {
|
||||
return err
|
||||
}
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
if slices.Index(args, "images") >= 0 {
|
||||
if r, err = images(); err != nil {
|
||||
for _, b := range all_benchmarks() {
|
||||
if slices.Index(args, b.name) < 0 {
|
||||
continue
|
||||
}
|
||||
r, err := b.run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.name = b.name
|
||||
results = append(results, r)
|
||||
}
|
||||
|
||||
fmt.Print(reset)
|
||||
fmt.Println(
|
||||
"These results measure the time it takes the terminal to fully parse all the data sent to it.")
|
||||
if opts.Render {
|
||||
fmt.Println("Note that not all data transmitted will be displayed as input parsing is typically asynchronous with rendering in high performance terminals.")
|
||||
} else {
|
||||
fmt.Println("Note that \x1b[31mrendering is suppressed\x1b[m (if the terminal supports the synchronized output escape code) to better benchmark parser performance. Use the --render flag to enable rendering.")
|
||||
}
|
||||
fmt.Println("Note that \x1b[31mrendering is suppressed\x1b[m (if the terminal supports the synchronized output escape code) to better benchmark parser performance, except in the render benchmark.")
|
||||
fmt.Println()
|
||||
fmt.Println("Results:")
|
||||
mlen := 10
|
||||
|
|
@ -526,14 +525,60 @@ func main(args []string) (err error) {
|
|||
for _, r := range results {
|
||||
present_result(r, mlen)
|
||||
}
|
||||
if opts.Output != "" {
|
||||
if err = write_results(opts.Output, results); err != nil {
|
||||
return fmt.Errorf("Failed to write results to %s with error: %w", opts.Output, err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type json_result struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Duration float64 `json:"duration_seconds"`
|
||||
DataSize int `json:"data_size_bytes"`
|
||||
Repetitions int `json:"repetitions"`
|
||||
MBPerSecond float64 `json:"mb_per_second"`
|
||||
CellsPerSecond float64 `json:"cells_per_second,omitempty"`
|
||||
}
|
||||
|
||||
func write_results(path string, results []result) error {
|
||||
ans := make([]json_result, len(results))
|
||||
for i, r := range results {
|
||||
ans[i] = json_result{
|
||||
Name: r.name, Description: r.desc, Duration: r.duration.Seconds(), DataSize: r.data_sz, Repetitions: r.repetitions,
|
||||
MBPerSecond: float64(r.data_sz) / r.duration.Seconds() / (1024. * 1024.),
|
||||
}
|
||||
if r.cells > 0 {
|
||||
ans[i].CellsPerSecond = float64(r.cells*r.repetitions) / r.duration.Seconds()
|
||||
}
|
||||
}
|
||||
data, err := json.MarshalIndent(ans, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, append(data, '\n'), 0o644)
|
||||
}
|
||||
|
||||
func help_text() string {
|
||||
var b strings.Builder
|
||||
b.WriteString("Benchmarking works by sending large amounts of data to the TTY device and waiting for the terminal to process the data and respond to queries sent to it in the data. ")
|
||||
b.WriteString("Rendering is suppressed during benchmarking to focus on parser performance, using the synchronized output escape code, except in the render benchmark. ")
|
||||
b.WriteString("Note that rendering in modern terminals is typically asynchronous so it wont be properly benchmarked by this kitten. ")
|
||||
b.WriteString("All benchmarks use the alternate screen, except the scrollback benchmark.\n\n")
|
||||
b.WriteString("To run only particular benchmarks, specify them on the command line. The available benchmarks are:\n\n")
|
||||
for _, bm := range all_benchmarks() {
|
||||
fmt.Fprintf(&b, "* :code:`%s`: %s\n\n", bm.name, bm.help)
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func EntryPoint(root *cli.Command) {
|
||||
sc := root.AddSubCommand(&cli.Command{
|
||||
Name: "__benchmark__",
|
||||
ShortDescription: "Run various benchmarks",
|
||||
HelpText: "To run only particular benchmarks, specify them on the command line from the set: " + strings.Join(all_benchamrks(), ", ") + ". Benchmarking works by sending large amount of data to the TTY device and waiting for the terminal to process the data and respond to queries sent to it in the data. By default rendering is suppressed during benchmarking to focus on parser performance. Use the --render flag to enable it, but be aware that rendering in modern terminals is typically asynchronous so it wont be properly benchmarked by this kitten.",
|
||||
HelpText: help_text(),
|
||||
Usage: "[options] [optional benchmark to run ...]",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cli.Command, args []string) (ret int, err error) {
|
||||
|
|
@ -554,14 +599,7 @@ func EntryPoint(root *cli.Command) {
|
|||
Help: "The number of repetitions of each benchmark",
|
||||
})
|
||||
sc.Add(cli.OptionSpec{
|
||||
Name: "--with-scrollback",
|
||||
Type: "bool-set",
|
||||
Help: "Use the main screen instead of the alt screen so speed of scrollback is also tested",
|
||||
Name: "--output -o",
|
||||
Help: "Also write the results to the specified file, as JSON. For every benchmark, the file has its name, description, duration, the amount of data sent, the number of repetitions, the throughput in MB per second and, for the text benchmarks, the number of cells drawn per second.",
|
||||
})
|
||||
sc.Add(cli.OptionSpec{
|
||||
Name: "--render",
|
||||
Type: "bool-set",
|
||||
Help: "Allow rendering of the data sent during tests. Note that modern terminals render asynchronously, so timings do not generally reflect render performance.",
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue