Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) # Sergey Senozhatsky, 2015
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) # sergey.senozhatsky.work@gmail.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) # This program is intended to plot a `slabinfo -X' stats, collected,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) # for example, using the following command:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #   while [ 1 ]; do slabinfo -X >> stats; sleep 1; done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) # Use `slabinfo-gnuplot.sh stats' to pre-process collected records
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) # and generate graphs (totals, slabs sorted by size, slabs sorted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) # by size).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) # Graphs can be [individually] regenerate with different ranges and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) # size (-r %d,%d and -s %d,%d options).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) # To visually compare N `totals' graphs, do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) # slabinfo-gnuplot.sh -t FILE1-totals FILE2-totals ... FILEN-totals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) min_slab_name_size=11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) xmin=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) xmax=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) width=1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) height=700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) mode=preprocess
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) usage()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	echo "Usage: [-s W,H] [-r MIN,MAX] [-t|-l] FILE1 [FILE2 ..]"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	echo "FILEs must contain 'slabinfo -X' samples"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	echo "-t 			- plot totals for FILE(s)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	echo "-l 			- plot slabs stats for FILE(s)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	echo "-s %d,%d		- set image width and height"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	echo "-r %d,%d		- use data samples from a given range"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) check_file_exist()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	if [ ! -f "$1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		echo "File '$1' does not exist"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) do_slabs_plotting()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	local file=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	local out_file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	local range="every ::$xmin"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	local xtic=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	local xtic_rotate="norotate"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	local lines=2000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	local wc_lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	check_file_exist "$file"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	out_file=`basename "$file"`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	if [ $xmax -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		range="$range::$xmax"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		lines=$((xmax-xmin))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	wc_lines=`cat "$file" | wc -l`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if [ $? -ne 0 ] || [ "$wc_lines" -eq 0 ] ; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		wc_lines=$lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if [ "$wc_lines" -lt "$lines" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		lines=$wc_lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if [ $((width / lines)) -gt $min_slab_name_size ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		xtic=":xtic(1)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		xtic_rotate=90
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) gnuplot -p << EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #!/usr/bin/env gnuplot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) set terminal png enhanced size $width,$height large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) set output '$out_file.png'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) set autoscale xy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) set xlabel 'samples'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) set ylabel 'bytes'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) set style histogram columnstacked title textcolor lt -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) set style fill solid 0.15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) set xtics rotate $xtic_rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) set key left above Left title reverse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) plot "$file" $range u 2$xtic title 'SIZE' with boxes,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	'' $range u 3 title 'LOSS' with boxes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		echo "$out_file.png"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) do_totals_plotting()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	local gnuplot_cmd=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	local range="every ::$xmin"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	local file=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if [ $xmax -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		range="$range::$xmax"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	for i in "${t_files[@]}"; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		check_file_exist "$i"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		file="$file"`basename "$i"`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		gnuplot_cmd="$gnuplot_cmd '$i' $range using 1 title\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			'$i Memory usage' with lines,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		gnuplot_cmd="$gnuplot_cmd '' $range using 2 title \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			'$i Loss' with lines,"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) gnuplot -p << EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #!/usr/bin/env gnuplot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) set terminal png enhanced size $width,$height large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) set autoscale xy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) set output '$file.png'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) set xlabel 'samples'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) set ylabel 'bytes'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) set key left above Left title reverse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) plot $gnuplot_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) EOF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		echo "$file.png"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) do_preprocess()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	local out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	local lines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	local in=$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	check_file_exist "$in"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	# use only 'TOP' slab (biggest memory usage or loss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	let lines=3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	out=`basename "$in"`"-slabs-by-loss"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	`cat "$in" | grep -A "$lines" 'Slabs sorted by loss' |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		egrep -iv '\-\-|Name|Slabs'\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		| awk '{print $1" "$4+$2*$3" "$4}' > "$out"`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		do_slabs_plotting "$out"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	let lines=3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	out=`basename "$in"`"-slabs-by-size"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	`cat "$in" | grep -A "$lines" 'Slabs sorted by size' |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		egrep -iv '\-\-|Name|Slabs'\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		| awk '{print $1" "$4" "$4-$2*$3}' > "$out"`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		do_slabs_plotting "$out"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	out=`basename "$in"`"-totals"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	`cat "$in" | grep "Memory used" |\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		awk '{print $3" "$7}' > "$out"`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	if [ $? -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		t_files[0]=$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		do_totals_plotting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) parse_opts()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	local opt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	while getopts "tlr::s::h" opt; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		case $opt in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 				mode=totals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			l)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				mode=slabs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 				array=(${OPTARG//,/ })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 				width=${array[0]}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 				height=${array[1]}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				array=(${OPTARG//,/ })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 				xmin=${array[0]}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				xmax=${array[1]}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 				usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 				exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			\?)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 				echo "Invalid option: -$OPTARG" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			:)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 				echo "-$OPTARG requires an argument." >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 				exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return $OPTIND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) parse_args()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	local idx=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	local p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	for p in "$@"; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		case $mode in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			preprocess)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				files[$idx]=$p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 				idx=$idx+1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 			totals)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				t_files[$idx]=$p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				idx=$idx+1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			slabs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				files[$idx]=$p
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 				idx=$idx+1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 				;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) parse_opts "$@"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) argstart=$?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) parse_args "${@:$argstart}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if [ ${#files[@]} -eq 0 ] && [ ${#t_files[@]} -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) case $mode in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	preprocess)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		for i in "${files[@]}"; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 			do_preprocess "$i"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	totals)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		do_totals_plotting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	slabs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		for i in "${files[@]}"; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			do_slabs_plotting "$i"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		echo "Unknown mode $mode" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) esac