libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit 4c8c42477dd927029de0b8dd0b6c7c556ff8e774
parent 9a8bf6a30e6e0696163141cf0c0088fb6ac61b4b
Author: Jacki <jacki@thejackimonster.de>
Date:   Tue,  4 Mar 2025 04:03:05 +0100

Add scripts to convert csv data from benchmarks into plots

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Abenchmark/tools/csv2plot.sh | 29+++++++++++++++++++++++++++++
Abenchmark/tools/header.sh | 33+++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/benchmark/tools/csv2plot.sh b/benchmark/tools/csv2plot.sh @@ -0,0 +1,29 @@ +#!/bin/sh +OUTPUT=$1 +X_AXIS=$2 +Y_AXIS=$3 +shift 3 + +HEADER=$(dirname $0)/header.sh + +if [ $# -lt 1 ]; then + exit +fi + +X_LABEL=$($HEADER $X_AXIS $1) +Y_LABEL=$($HEADER $Y_AXIS $1) + +X_MIN=$(cat $1 | awk 'NR != 1 {print $'$X_AXIS'}' | sort -h | head -n1) +X_MAX=$(cat $1 | awk 'NR != 1 {print $'$X_AXIS'}' | sort -h | tail -n1) + +PLOT="" +while [ $# -gt 0 ]; do + if [ "$PLOT" != "" ]; then + PLOT="$PLOT, " + fi + PLOT="$PLOT'$1' using $X_AXIS:$Y_AXIS title '$2' with boxes lw 1.25" + shift 2 +done + +gnuplot -e "set terminal pdf; set output '$OUTPUT'; set datafile separator ' '; set xlabel '$X_LABEL' font ',12'; set ylabel '$Y_LABEL' font ',12'; set boxwidth 0.8; set xrange [$(($X_MIN - 1)):$(($X_MAX + 1))]; plot $PLOT" + diff --git a/benchmark/tools/header.sh b/benchmark/tools/header.sh @@ -0,0 +1,33 @@ +#!/bin/sh +N=$1 +shift 1 +awk -v n=$N ' +NR==1 { + count = 0 + in_quote = 0 + val = "" + for (i = 1; i <= NF; i++) { + field = $i + if (in_quote) { + val = val " " field + if (field ~ /"$/) { + in_quote = 0 + count++ + if (count == n) { + print val + exit + } + } + } else if (field ~ /^"/ && field !~ /"$/) { + in_quote = 1 + val = field + } else { + count++ + if (count == n) { + print field + exit + } + } + } +} +' $@ | tr -d '"'