The visualization was six unrelated widgets - a histogram, a timeline, an error-rate bar, percentile bars, a fill gauge, plus a dashboard, heatmap and "real-time monitor" charting simulated CPU/memory/disk data. Colour was decorative and inconsistent, and the result did not read as a benchmark tool. Replace all of it with one drawing primitive: a vertical column chart with a zero-based labelled y-axis, a baseline and a labelled x-axis. Four charts share that shape - throughput over time (failures stacked in red), response time over time, response time distribution, and response time percentiles. Colour now carries meaning only: cyan is data, amber is the tail (p95+), red is failure. Charts size themselves to the terminal width. The summary keeps every number it had, laid out as aligned key/value blocks under section rules, with the ApacheBench percentile table as a 3-column grid. Fixes found along the way: - "Latency over the run" plotted the sorted durations, so it was always a monotonic ramp rather than a timeline. Requests now record a start offset relative to the run, so the time-axis charts show what actually happened. - The throughput gauge was scaled against a hardcoded 1000.0 req/s, so it read a near-zero percentage regardless of the target. - The live progress line recomputed statistics over every completed request on every completion, an O(n^2) cost inside the benchmark loop. It is now throttled to ~20 Hz and skipped entirely when stdout is not a terminal. Colour and the progress bar are gated on isatty(), so redirected output is plain, greppable text with no escape codes. A heavy tail (p50 57 ms, max 1525 ms) previously collapsed the distribution into a single column. The chart now clips its axis at p95 when the maximum dwarfs it and states so beneath the chart; well-behaved runs are never clipped and the full range stays in the footer either way. Also drop 77 lines of dead simulation code from main.c, wire graphs.c into the Makefile, untrack the built binary, and add a .gitignore. Builds warning-free at -Wall -Wextra; valgrind clean on the loaded, single-request and all-failed paths. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GCMSMcgcwnH9a8hhaLsg6j
39 lines
1.4 KiB
C
39 lines
1.4 KiB
C
// retoor <retoor@molodetz.nl>
|
|
|
|
#ifndef GRAPHS_H
|
|
#define GRAPHS_H
|
|
|
|
/*
|
|
* Column-chart renderer for abr.
|
|
*
|
|
* Every visual in abr is the same object: a vertical bar chart with a labelled
|
|
* y-axis, a baseline and an x-axis. One shape, one colour language, no
|
|
* decoration. Charts adapt to the terminal width and degrade to plain ASCII
|
|
* when colour is turned off.
|
|
*/
|
|
|
|
/* Enable or disable ANSI colour. Call once at start-up (e.g. isatty(1)). */
|
|
void graph_set_color(int enabled);
|
|
|
|
/* Width in columns the charts will occupy, for aligning surrounding output. */
|
|
int graph_width(void);
|
|
|
|
/* Bold section rule, e.g. graph_section("Latency"). */
|
|
void graph_section(const char *title);
|
|
|
|
/* Distribution of response times. Input need not be sorted. */
|
|
void graph_latency_histogram(const double *durations_ms, int count);
|
|
|
|
/* Completed requests per time slice; failures stack on top in red. */
|
|
void graph_throughput(const double *finish_ms, const int *failed, int count,
|
|
double total_seconds);
|
|
|
|
/* Mean response time per time slice, over successful requests only. */
|
|
void graph_latency_over_time(const double *finish_ms, const double *durations_ms,
|
|
const int *failed, int count, double total_seconds);
|
|
|
|
/* Response time percentiles as columns; the tail (p95+) is highlighted. */
|
|
void graph_percentiles(const double *durations_ms, int count);
|
|
|
|
#endif
|