1762282465
This commit is contained in:
@@ -17,6 +17,7 @@ logfile=/tmp/sillylog.tmp # can beee a temp fiel
|
|||||||
input="$@" # da command as a string or as args
|
input="$@" # da command as a string or as args
|
||||||
duration_microseconds=0
|
duration_microseconds=0
|
||||||
duration_seconds=0
|
duration_seconds=0
|
||||||
|
csv_file="${input%.*}.csv"
|
||||||
test_cmd=""
|
test_cmd=""
|
||||||
start_seconds=$(date +%s)
|
start_seconds=$(date +%s)
|
||||||
|
|
||||||
@@ -31,6 +32,11 @@ if [ -f "$logfile" ]; then
|
|||||||
rm -f "$logfile"
|
rm -f "$logfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# maek sure da log fileee DIESASDRGVWERT
|
||||||
|
if [ -f "$csv_file" ]; then
|
||||||
|
rm -f "$csv_file"
|
||||||
|
fi
|
||||||
|
|
||||||
measure_performance () {
|
measure_performance () {
|
||||||
# use microseconds for timing for ONE MILLION DOLLARS more times resolution
|
# use microseconds for timing for ONE MILLION DOLLARS more times resolution
|
||||||
start_unixmicroseconds=$(date +"%s%6N") # get start microseconds fast as possible before run
|
start_unixmicroseconds=$(date +"%s%6N") # get start microseconds fast as possible before run
|
||||||
@@ -44,7 +50,7 @@ measure_performance () {
|
|||||||
duration_microseconds=$(($end_unixmicroseconds - $start_unixmicroseconds))
|
duration_microseconds=$(($end_unixmicroseconds - $start_unixmicroseconds))
|
||||||
duration_seconds=$(($duration_microseconds / 1000000)) # seconds = microseconds / 1,000,000
|
duration_seconds=$(($duration_microseconds / 1000000)) # seconds = microseconds / 1,000,000
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ ! -f "$input" ]; then
|
||||||
echo "testing your gay littel command: $test_cmd"
|
echo "testing your gay littel command: $test_cmd"
|
||||||
# parse and show infos
|
# parse and show infos
|
||||||
cat "$logfile" | sed '/^#\|^$\|^Linux/d' | tr -s ' ' ',' | awk -F, '{ cpup += $8; memk += $13; memp += $14; rkbs += $15; wkbs += $15 } END { print "\nCPU:",cpup/NR,"\nMemory Usage (KiB):",memk/NR,"\nMemory Usage %:",memp/NR,"\nKiB Read Per Second:",rkbs/NR,"\nKiB Written Per Second:",wkbs/NR }'
|
cat "$logfile" | sed '/^#\|^$\|^Linux/d' | tr -s ' ' ',' | awk -F, '{ cpup += $8; memk += $13; memp += $14; rkbs += $15; wkbs += $15 } END { print "\nCPU:",cpup/NR,"\nMemory Usage (KiB):",memk/NR,"\nMemory Usage %:",memp/NR,"\nKiB Read Per Second:",rkbs/NR,"\nKiB Written Per Second:",wkbs/NR }'
|
||||||
@@ -76,20 +82,19 @@ else
|
|||||||
results_log=$1.csv # todo: do file ext trickery
|
results_log=$1.csv # todo: do file ext trickery
|
||||||
len=$(wc -l "$input" | awk '{print $1}') # num of lines in da fiel
|
len=$(wc -l "$input" | awk '{print $1}') # num of lines in da fiel
|
||||||
count=1
|
count=1
|
||||||
csv_file="${input%.*}.csv"
|
|
||||||
|
|
||||||
# if [ -f "$csv_file" ]; then
|
# if [ -f "$csv_file" ]; then
|
||||||
# rm -f "$csv_file"
|
# rm -f "$csv_file"
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
# add da csv headers to the results fiel
|
# add da csv headers to the results fiel
|
||||||
echo "0Position,CPU %,Memory (KiB),Memory %,KiB Read/Second,KiB Written/Second,Duration Microseconds,Command,Return Code,Seconds Elapsed" > "$csv_file"
|
echo "0Position,CPU %,Memory (KiB),Memory %,KiB Read/Second,KiB Written/Second,Duration Microseconds,Command,Return Code,Seconds Elapsed" >> "$csv_file"
|
||||||
|
|
||||||
cat "$input" | \
|
cat "$input" | \
|
||||||
while read line; do
|
while read line; do
|
||||||
test_cmd="$line"
|
test_cmd="$line"
|
||||||
position="$count/$len"
|
position="$count/$len"
|
||||||
measure_performance batch
|
measure_performance
|
||||||
count=$(($count + 1))
|
count=$(($count + 1))
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user