dat silly measure_performance command almost workan
This commit is contained in:
1 parent
48266b3287
commit
2dd270b9b0
3 files changed
+83
-26
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
Position,CPU %,Memory (KiB),Memory %,KiB Read/Second,KiB Written/Second,Duration Microseconds,Command,Return Code,Seconds Elapsed
|
||||||
|
1/5,0,1728,0.01,0,0,10008736,sleep10,0,10
|
||||||
|
2/5,1.07857,8173.71,0.0528571,0,36700,25850195,wgethttps://github.com/espressif/esp-idf/releases/download/v5.5.1/esp-idf-v5.5.1.zip-P/tmp/file.tmp,0,36
|
||||||
|
3/5,2.38769,33324,0.204615,0.0615385,19762.5,26261108,oniuxcurl-shttps://canhazip.com,0,62
|
||||||
|
4/5,2.87053,37945.1,0.232105,-0.0105263,13522.1,25054283,oniuxcurl-shttps://canhazip.com,0,88
|
||||||
|
5/5,3.1292,43786.4,0.268,-0.008,10277.3,25753552,oniuxcurl-shttps://canhazip.com,0,113
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
sleep 10
|
||||||
|
wget https://github.com/espressif/esp-idf/releases/download/v5.5.1/esp-idf-v5.5.1.zip -P /tmp/file.tmp
|
||||||
|
oniux curl -s https://canhazip.com
|
||||||
|
oniux curl -s https://canhazip.com
|
||||||
|
oniux curl -s https://canhazip.com
|
||||||
|
rm -f /tmp/file.tmp
|
||||||
@@ -5,14 +5,20 @@
|
|||||||
## measure_performance "my_command -with -args"
|
## measure_performance "my_command -with -args"
|
||||||
|
|
||||||
# todo: calculate human readable sizes for mem, r and w
|
# todo: calculate human readable sizes for mem, r and w
|
||||||
# todo: loop through list of commands supplied by a file
|
# todo: batch mode
|
||||||
|
## loop through list of commands supplied by a file
|
||||||
## output da actual log for dis one ig lmao idk
|
## output da actual log for dis one ig lmao idk
|
||||||
|
### log results to a file named after the input file
|
||||||
|
### log format csv with titles
|
||||||
|
|
||||||
cmd="$@" # da command as a string or as args
|
# glooboos
|
||||||
start_date=$(date)
|
poll_seconds=5
|
||||||
start_unixseconds=$(date +%s)
|
logfile=/tmp/sillylog.tmp # can beee a temp fiel
|
||||||
poll_seconds=2
|
input="$@" # da command as a string or as args
|
||||||
logfile=/tmp/sillylog.csv
|
duration_microseconds=0
|
||||||
|
duration_seconds=0
|
||||||
|
test_cmd=""
|
||||||
|
start_seconds=$(date +%s)
|
||||||
|
|
||||||
# throw a fit if no args supplied
|
# throw a fit if no args supplied
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
@@ -20,23 +26,62 @@ if [ -z "$1" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "testing your gay little command $cmd"
|
# maek sure da log fileee DIESASDRGVWERT
|
||||||
# start times
|
if [ -f "$logfile" ]; then
|
||||||
start_unixmicroseconds=$(date +"%s%6N") # get start microseconds fast as possible before run
|
rm -f "$logfile"
|
||||||
# run the command with pidstat monitoring it, using eval to handle strings and args methods
|
fi
|
||||||
eval "pidstat -h -H -d -r -u -I $poll_seconds -e $cmd >> \"$logfile\""
|
|
||||||
# get exit code
|
measure_performance () {
|
||||||
ret=$?
|
# use microseconds for timing for ONE MILLION DOLLARS more times resolution
|
||||||
# end times
|
start_unixmicroseconds=$(date +"%s%6N") # get start microseconds fast as possible before run
|
||||||
## microseconds
|
|
||||||
end_unixmicroseconds=$(date +"%s%6N") # get dis fast for accuracy
|
# run the command with pidstart (-e)
|
||||||
duration_microseconds=$(($end_unixmicroseconds - $start_unixmicroseconds))
|
eval "pidstat -h -H -d -r -u -I $poll_seconds -e $test_cmd >> \"$logfile\""
|
||||||
## seconds
|
ret=$? # get da return code
|
||||||
duration_seconds=$(($duration_microseconds / 1000000)) # seconds = microseconds / 1,000,000
|
|
||||||
# parse da fiel
|
# calculate durations
|
||||||
## remove lines starting with # (comments), empty lines, and those starting with Linux so its a pure csv
|
end_unixmicroseconds=$(date +"%s%6N") # get dis fast for accuracy
|
||||||
## then squash spaces and replace with commas
|
duration_microseconds=$(($end_unixmicroseconds - $start_unixmicroseconds))
|
||||||
## them awk by delimiter comma to output
|
duration_seconds=$(($duration_microseconds / 1000000)) # seconds = microseconds / 1,000,000
|
||||||
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 }' #$1,$3,$8,$13,$14,$15,$16,$17 }'
|
|
||||||
# add footer
|
if [ -z "$1" ]; then
|
||||||
echo -e "Duration Seconds: $duration_seconds\nDuration Microseconds: $duration_microseconds\nReturn Code: $ret"
|
echo "testing your gay littel command: $test_cmd"
|
||||||
|
# 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 }'
|
||||||
|
|
||||||
|
# nao add da rest
|
||||||
|
echo -e "Duration Seconds: $duration_seconds\nDuration Microseconds: $duration_microseconds\nReturn Code: $ret"
|
||||||
|
else
|
||||||
|
elapsed_seconds=$((`date +%s` - $start_seconds))
|
||||||
|
# parse and appand dem 2 da csv
|
||||||
|
cat "$logfile" | sed '/^#\|^$\|^Linux/d' | tr -s ' ' ',' | awk -F, "{cpup+= \$8;memk+=\$13;memp +=\$14;rkbs+=\$15;wkbs+=\$16 } END {print \"$position\",\",\",cpup/NR,\",\",memk/NR,\",\",memp/NR,\",\",rkbs/NR,\",\",wkbs/NR,\",\",\"$duration_microseconds\",\",\",\"$test_cmd\",\",\",\"$ret\",\",\",\"$elapsed_seconds\"}" | tr -d ' ' | tee -a "$csv_file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# main
|
||||||
|
## if oneshot mode
|
||||||
|
if [ ! -f "$input" ]; then
|
||||||
|
test_cmd="$@"
|
||||||
|
measure_performance
|
||||||
|
## if batch mode
|
||||||
|
else
|
||||||
|
# settans
|
||||||
|
results_log=$1.csv # todo: do file ext trickery
|
||||||
|
len=$(wc -l "$input" | awk '{print $1}') # num of lines in da fiel
|
||||||
|
count=1
|
||||||
|
csv_file="${input%.*}.csv"
|
||||||
|
|
||||||
|
if [ -f "$csv_file" ]; then
|
||||||
|
rm -f "$csv_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# add da csv headers to the results fiel
|
||||||
|
echo "Position,CPU %,Memory (KiB),Memory %,KiB Read/Second,KiB Written/Second,Duration Microseconds,Command,Return Code,Seconds Elapsed" | tee "$csv_file"
|
||||||
|
cat "$input" | \
|
||||||
|
while read line; do
|
||||||
|
test_cmd="$line"
|
||||||
|
position="$count/$len"
|
||||||
|
measure_performance batch
|
||||||
|
count=$(($count + 1))
|
||||||
|
done
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user