Turning Raw Performance Test Logs into Readable Text Charts with Groovy
This article explains how to replace cumbersome Python‑Plotly visualizations of performance test logs with a lightweight Groovy solution that generates plain‑text bar charts directly in the shell or email, using Unicode block characters and a bucket‑based median algorithm.
In performance testing, results are often stored as raw JSON logs that look like cold, unreadable data. While the data can be saved to a database and visualized with Python + Plotly, doing so on a remote test server is inefficient because it requires transferring files, running separate scripts, and mapping test service files for inspection.
The author proposes a Groovy‑compatible, pure‑text visualization that can be displayed directly in a shell window or embedded in an email. The approach uses a set of Unicode block characters (▁▂▃▄▅▆▇█) to represent different height levels, dividing the sorted data into 23 buckets and using each bucket's median as the representative value.
The algorithm works as follows:
Sort the performance data.
Split the sorted list into BUCKET_SIZE (23) equal parts.
Take the median of each bucket.
Map each median to a number of block characters based on its proportion to the maximum median (800 in the example).
Convert the resulting strings into a two‑dimensional String[][] array, then transpose it to obtain a vertical layout.
Assemble the final chart using a StringBuffer, adding headers and footers for context.
The core constants include:
public static final String[] PERCENT = {" ", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"};The main method statistics(List<Integer> data) implements the steps above, producing a text block such as:
>>>响应时间分布图,横轴排序分成桶的序号,纵轴每个桶的中位数<<
--<中位数数据最小值为:... ms,最大值:... ms>--
▁▂▃▅▇▇▇▇▇
▂▃▅▆▇▇▇▇▇
...A blockquote notes that the choice of 23 buckets stems from a calculation that makes the division faster.
不要问为啥选23,问就是计算式计算23是被除数时比较快。
An example image of the generated chart is included below.
This solution eliminates the need for external plotting tools, works entirely within the test server’s shell, and produces an instantly readable visual representation of performance metrics.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
