diff --git a/benchmarks/Makefile b/benchmarks/Makefile index 51aa0942ab..cb66613105 100644 --- a/benchmarks/Makefile +++ b/benchmarks/Makefile @@ -48,6 +48,9 @@ TSBS_WORKERS ?= 4 TSBS_QUERY_TYPE := cpu-max-all-8 TSBS_DATA_FILE := /tmp/tsbs-data-$(TSBS_SCALE)-$(TSBS_START)-$(TSBS_END)-$(TSBS_STEP).gz TSBS_QUERY_FILE := /tmp/tsbs-queries-$(TSBS_QUERY_TYPE)-$(TSBS_SCALE)-$(TSBS_START)-$(TSBS_END)-$(TSBS_QUERIES).gz +TSBS_LOAD_RESULT_CSV_FILE := /tmp/tsbs-load-$(TSBS_SCALE)-$(TSBS_START)-$(TSBS_END)-$(TSBS_STEP).csv +TSBS_LOAD_RESULT_CSV_FILE_COMPARE ?= +TSBS_PLOT_SCRIPT := $(shell pwd)/benchmarks/plot-load.sh # For cluster setup use http://vminsert:8480/insert/0/influx/write TSBS_WRITE_URLS ?= http://localhost:8428/write # For cluster setup use http://vmselect:8481/select/0/prometheus @@ -76,7 +79,10 @@ tsbs-generate-data: # Load data into VictoriaMetrics tsbs-load-data: - cat $(TSBS_DATA_FILE) | gunzip | /tmp/tsbs/bin/tsbs_load_victoriametrics --workers=$(TSBS_WORKERS) --urls=$(TSBS_WRITE_URLS) + cat $(TSBS_DATA_FILE) | gunzip | /tmp/tsbs/bin/tsbs_load_victoriametrics \ + --workers=$(TSBS_WORKERS) \ + --urls=$(TSBS_WRITE_URLS) \ + 2>/dev/tty | tee $(TSBS_LOAD_RESULT_CSV_FILE) curl -s $(TSBS_METRICS_URL) | grep \ -e process_cpu_seconds_user_total \ -e process_cpu_seconds_system_total \ @@ -133,3 +139,16 @@ tsbs-run-queries-all: # Too heavy: retrieves 1B samples # $(MAKE) tsbs-run-queries TSBS_QUERY_TYPE=double-groupby-all + +# Plot the data load `per interval metrics/s` measurements +# +# To plot measurements collected during the recent benchmark, run +# make tsbs-plot-load +# +# To plot the measurements from some other benchmark, run +# make tsbs-plot-load TSBS_LOAD_RESULT_CSV_FILE=/path/to/file.csv +# +# To plot the measurements from two benchmarks, run +# make tsbs-plot-load TSBS_LOAD_RESULT_CSV_FILE=/path/to/file1.csv TSBS_LOAD_RESULT_CSV_FILE_COMPARE=/path/to/file2.csv +tsbs-plot-load: + $(TSBS_PLOT_SCRIPT) $(TSBS_LOAD_RESULT_CSV_FILE) $(TSBS_LOAD_RESULT_CSV_FILE_COMPARE) diff --git a/benchmarks/plot-load.sh b/benchmarks/plot-load.sh new file mode 100755 index 0000000000..2692978f3a --- /dev/null +++ b/benchmarks/plot-load.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Check the number of arguments +if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then + echo "Usage: $(basename $0) file1.csv [file2.csv]" + exit 1 +fi + +file1="$1" +file2="$2" + +# Check if the files exist +if [ ! -f "$file1" ]; then + echo "File not found: $file1" + exit 1 +fi + +if [ -n "$file2" ] && [ ! -f "$file2" ]; then + echo "File not found: $file2" + exit 1 +fi + +# Temporary file for plot data +plotdata="/tmp/tsbs_plot.dat" + +if [ -z "$file2" ]; then + # === One file === + awk -F, '/^Summary:/ {exit} NR > 1 {print $1, $2}' "$file1" > "$plotdata" +else + # === Two files === + + # Get time and per.metric/s from file1 + awk -F, '/^Summary:/ {exit} NR > 1 {print $1, $2}' "$file1" > /tmp/file1.dat + # Get per.metric/s from file2 + awk -F, '/^Summary:/ {exit} NR > 1 {print $2}' "$file2" > /tmp/file2.dat + # Merge by rows: time, val1, val2 + paste /tmp/file1.dat /tmp/file2.dat | awk '{print $1, $2, $3}' > "$plotdata" +fi + +# === Build plot dynamically === +gnuplot -persist <<-EOF + set datafile separator " " + set title "per.metric/s" + set xlabel "Timestamp" + set xdata time + set timefmt "%s" + set format x "%H:%M:%S" + set ylabel "per. metric/s" + set format y "%'.0f" + set grid + + plot "$plotdata" using 1:2 with lines title "$(basename "$file1")" \ + $( [[ -n "$file2" ]] && echo ", \\ + \"$plotdata\" using 1:3 with lines title \"$(basename "$file2")\"" ) +EOF