diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-15 13:04:32 +0300 |
| commit | bdaedce69b17b654bd0060579dd9b9ff120009b5 (patch) | |
| tree | 0e9cd8597652263a96c48ba678fb0b66e1fc131b /benchmarks | |
| parent | ba75c8b0a1bba03ad92c53375432f122ddb4cb98 (diff) | |
| parent | dcebf9c7f954a55350b68d0ead1935612c4e2e05 (diff) | |
Merge branch 'wt/rename' into api-hardening
# Conflicts:
# README.md
Diffstat (limited to 'benchmarks')
| -rw-r--r-- | benchmarks/hist_bench.c | 24 | ||||
| -rw-r--r-- | benchmarks/meson.build | 2 | ||||
| -rw-r--r-- | benchmarks/term_resize_bench.c | 24 | ||||
| -rw-r--r-- | benchmarks/term_write_bench.c | 20 |
4 files changed, 35 insertions, 35 deletions
diff --git a/benchmarks/hist_bench.c b/benchmarks/hist_bench.c index 2cf5608..bf3d1ca 100644 --- a/benchmarks/hist_bench.c +++ b/benchmarks/hist_bench.c @@ -14,7 +14,7 @@ static double now(void) /* Rows shaped like the term-write-bench lines that scroll into history. */ static int make_row(const char *name, struct cell *row) { - struct cell d = { ' ', TERM_COLOR_FG, TERM_COLOR_BG, 0, 0 }; + struct cell d = { ' ', WSAP_VTCORE_COLOR_FG, WSAP_VTCORE_COLOR_BG, 0, 0 }; int n = 0; if (!strcmp(name, "ascii-row")) { const char *s = "The quick brown fox jumps over the lazy dog. 0123456789"; @@ -37,15 +37,15 @@ static int make_row(const char *name, struct cell *row) row[n] = d; row[n].c = (uint8_t)s[n]; if (n < 3) - row[n].fg = term_color_index(1); + row[n].fg = wsap_vtcore_color_index(1); if (n > 3) - row[n].fg = term_color_rgb(12, 34, 56); + row[n].fg = wsap_vtcore_color_rgb(12, 34, 56); } } else if (!strcmp(name, "fg-char-row")) { for (; n < 120; n++) { row[n] = d; row[n].c = 'a' + (uint32_t)(n % 26); - row[n].fg = term_color_rgb((uint8_t)n, (uint8_t)(n * 3), (uint8_t)(n * 7)); + row[n].fg = wsap_vtcore_color_rgb((uint8_t)n, (uint8_t)(n * 3), (uint8_t)(n * 7)); } } return n; @@ -55,7 +55,7 @@ int main(int argc, char **argv) { int iterations = argc > 1 ? atoi(argv[1]) : 10000000; struct hist h; - if (!term_hist_init(&h, 10000, 8 * 1024 * 1024)) { + if (!wsap_vtcore_hist_init(&h, 10000, 8 * 1024 * 1024)) { fprintf(stderr, "failed to initialize hist\n"); return EXIT_FAILURE; } @@ -63,31 +63,31 @@ int main(int argc, char **argv) const char *line = "abcdefghijklmnopqrstuvwxyz\n"; int len = (int)strlen(line); for (int i = 0; i < 10000; i++) - term_hist_push_ascii(&h, line, len, NULL, false); + wsap_vtcore_hist_push_ascii(&h, line, len, NULL, false); double t0 = now(); for (int i = 0; i < iterations; i++) - term_hist_push_ascii(&h, line, len, NULL, false); + wsap_vtcore_hist_push_ascii(&h, line, len, NULL, false); double elapsed = now() - t0; printf("%-12s %6.2f ns/line %.2f GiB/s (%d B/line)\n", "ascii", elapsed * 1e9 / iterations, (double)iterations * len / (1024.0 * 1024.0 * 1024.0) / elapsed, len); - term_hist_free(&h); + wsap_vtcore_hist_free(&h); static const char *rows[] = { "ascii-row", "cjk-row", "colors-row", "fg-char-row" }; for (size_t k = 0; k < sizeof(rows) / sizeof(rows[0]); k++) { struct cell row[128]; int n = make_row(rows[k], row); int iters = iterations / 4; - if (!term_hist_init(&h, 4096, 0)) + if (!wsap_vtcore_hist_init(&h, 4096, 0)) return EXIT_FAILURE; for (int i = 0; i < 10000; i++) - term_hist_push_row(&h, row, n, false, NULL); + wsap_vtcore_hist_push_row(&h, row, n, false, NULL); t0 = now(); for (int i = 0; i < iters; i++) - term_hist_push_row(&h, row, n, false, NULL); + wsap_vtcore_hist_push_row(&h, row, n, false, NULL); elapsed = now() - t0; printf("%-12s %6.2f ns/row (%d cells)\n", rows[k], elapsed * 1e9 / iters, n); - term_hist_free(&h); + wsap_vtcore_hist_free(&h); } return EXIT_SUCCESS; } diff --git a/benchmarks/meson.build b/benchmarks/meson.build index ef78f28..bd508b6 100644 --- a/benchmarks/meson.build +++ b/benchmarks/meson.build @@ -6,7 +6,7 @@ foreach entry : [ benchmark(entry[0], executable(entry[0], entry[1], c_args: ['-D_POSIX_C_SOURCE=200809L'], - dependencies: term_internal_dep, + dependencies: wsap_vtcore_internal_dep, build_by_default: false), timeout: 600, ) diff --git a/benchmarks/term_resize_bench.c b/benchmarks/term_resize_bench.c index 08634d1..2899dae 100644 --- a/benchmarks/term_resize_bench.c +++ b/benchmarks/term_resize_bench.c @@ -1,4 +1,4 @@ -#include "term/term.h" +#include "wsap_vtcore/wsap_vtcore.h" #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -34,7 +34,7 @@ static int cmp_double(const void *a, const void *b) enum content { SHORT, WRAPPED, MIXED, PROMPT, WIDE, CONTENT_COUNT }; static const char *content_names[] = {"short", "wrapped", "mixed", "prompt", "wide"}; -static void emit_line(struct term *t, enum content kind, int n, int cols) +static void emit_line(struct wsap_vtcore *t, enum content kind, int n, int cols) { char line[4096]; int len = 0; @@ -74,12 +74,12 @@ static void emit_line(struct term *t, enum content kind, int n, int cols) break; } (void)cols; - term_feed(t, line, (size_t)len, 0); + wsap_vtcore_feed(t, line, (size_t)len, 0); } -static struct term *make_filled(enum content kind, int cols, int rows, int history) +static struct wsap_vtcore *make_filled(enum content kind, int cols, int rows, int history) { - struct term *t = term_new(&(struct term_options){ + struct wsap_vtcore *t = wsap_vtcore_new(&(struct wsap_vtcore_options){ .size = { .x = cols, .y = rows }, .scrollback = history, }); @@ -89,10 +89,10 @@ static struct term *make_filled(enum content kind, int cols, int rows, int histo return t; } -static void resize(struct term *t, int cols, int rows) +static void resize(struct wsap_vtcore *t, int cols, int rows) { - if (!term_resize(t, (struct term_vector2i){ .x = cols, .y = rows })) { - fprintf(stderr, "term_resize failed: out of memory\n"); + if (!wsap_vtcore_resize(t, (struct wsap_vtcore_vector2i){ .x = cols, .y = rows })) { + fprintf(stderr, "wsap_vtcore_resize failed: out of memory\n"); exit(EXIT_FAILURE); } } @@ -113,12 +113,12 @@ static double bench_pair(enum content kind, int from_cols, int to_cols, int rows { double worst = 0; for (int i = 0; i < samples; i++) { - struct term *t = make_filled(kind, from_cols, rows, history); + struct wsap_vtcore *t = make_filled(kind, from_cols, rows, history); if (!t) exit(EXIT_FAILURE); double start = now(); resize(t, to_cols, rows); double ms = (now() - start) * 1e3; - term_free(t); + wsap_vtcore_free(t); out[i] = ms; if (ms > worst) worst = ms; } @@ -132,14 +132,14 @@ static int bench_drag(enum content kind, int from_cols, int to_cols, int rows, int n = 0; int step = from_cols > to_cols ? -1 : 1; for (int p = 0; p < passes; p++) { - struct term *t = make_filled(kind, from_cols, rows, history); + struct wsap_vtcore *t = make_filled(kind, from_cols, rows, history); if (!t) exit(EXIT_FAILURE); for (int c = from_cols + step; c != to_cols + step; c += step) { double start = now(); resize(t, c, rows); out[n++] = (now() - start) * 1e3; } - term_free(t); + wsap_vtcore_free(t); } return n; } diff --git a/benchmarks/term_write_bench.c b/benchmarks/term_write_bench.c index 7649ed8..f393b4c 100644 --- a/benchmarks/term_write_bench.c +++ b/benchmarks/term_write_bench.c @@ -1,4 +1,4 @@ -#include "term/term.h" +#include "wsap_vtcore/wsap_vtcore.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -20,13 +20,13 @@ static int cmp_double(const void *a, const void *b) /* Timed sample: iterations full-buffer writes split at raw byte offsets, so a * chunk smaller than len cuts UTF-8/CSI sequences mid-stream and exercises the * parser's save-and-resume path, like real PTY reads do. */ -static double run_sample(struct term *t, const char *buf, size_t len, +static double run_sample(struct wsap_vtcore *t, const char *buf, size_t len, size_t chunk, int iterations, unsigned flags) { double start = now(); for (int i = 0; i < iterations; i++) { for (size_t pos = 0; pos < len; pos += chunk) - term_feed(t, buf + pos, len - pos < chunk ? len - pos : chunk, flags); + wsap_vtcore_feed(t, buf + pos, len - pos < chunk ? len - pos : chunk, flags); } return now() - start; } @@ -146,25 +146,25 @@ int main(int argc, char **argv) } for (int k = 0; k < nchunks; k++) { size_t ck = chunks[k]; - const char *env_cols = getenv("TERM_COLS"); + const char *env_cols = getenv("WSAP_VTCORE_COLS"); int cols_val = env_cols ? atoi(env_cols) : 120; - struct term *t = term_new(&(struct term_options){ + struct wsap_vtcore *t = wsap_vtcore_new(&(struct wsap_vtcore_options){ .size = { .x = cols_val, .y = 40 }, .scrollback = BENCH_SCROLLBACK, }); if (!t) { - fprintf(stderr, "term_new failed: TERM_COLS must be 0 to %d\n", TERM_MAX_COLS); + fprintf(stderr, "wsap_vtcore_new failed: WSAP_VTCORE_COLS must be 0 to %d\n", WSAP_VTCORE_MAX_COLS); return EXIT_FAILURE; } /* manyline has bare LFs: each one also returns the cursor to * column 0, as a tty with ONLCR does. */ - unsigned flags = !strcmp(cases[c].name, "manyline") ? TERM_FEED_ONLCR : 0; + unsigned flags = !strcmp(cases[c].name, "manyline") ? WSAP_VTCORE_FEED_ONLCR : 0; if (!strncmp(cases[c].name, "margin-", 7)) { const char setup[] = "\033[5;36r\033[36;1H"; - term_feed(t, setup, sizeof(setup) - 1, 0); + wsap_vtcore_feed(t, setup, sizeof(setup) - 1, 0); } else if (strstr(cases[c].name, "-burst")) { const char setup[] = "\033[40;1H"; - term_feed(t, setup, sizeof(setup) - 1, 0); + wsap_vtcore_feed(t, setup, sizeof(setup) - 1, 0); } /* Untimed warmup reaches steady-state scroll so rep 1 isn't a * cold outlier. */ @@ -179,7 +179,7 @@ int main(int argc, char **argv) printf("%-9s %6zu %10.2f %10.2f %10.2f %8.3f\n", cases[c].name, ck, med, min, max, samples[reps / 2] * 1e9 / bytes); - term_free(t); + wsap_vtcore_free(t); } } if (!matched) fprintf(stderr, "unknown benchmark case: %s\n", argv[1]); |
