Skip to content

Instantly share code, notes, and snippets.

@dvtalk
Last active June 6, 2022 02:56
Show Gist options
  • Select an option

  • Save dvtalk/0690340d60ad691e58e270ecb94e6c56 to your computer and use it in GitHub Desktop.

Select an option

Save dvtalk/0690340d60ad691e58e270ecb94e6c56 to your computer and use it in GitHub Desktop.
example csh script for filtering, get average, max, min value of a input log file
#!/bin/csh
##############################
#Usage: perf_min_max_avg.csh perf_log.csv
#Usage: unit is ps
# example log of perf_log.csv is as below
# ip, loop_idx, obj_id, start_time, end_time, processing_time
# UART, 1, 577694555, 387336768.000 ps, 390426774.000 ps, 3090006.000 ps,
# UART, 2, 1477172896, 390792775.000 ps, 405858805.000 ps, 15066030.000 ps,
# UART, 3, 2120155115, 406414806.000 ps, 407434808.000 ps, 1020002.000 ps,
# UART, 4, 1486474252, 407834809.000 ps, 417818829.000 ps, 9984020.000 ps,
# UART, 5, 1513920755, 418494830.000 ps, 432042858.000 ps, 13548028.000 ps,
# UART, 6, 2050096434, 432454858.000 ps, 436642867.000 ps, 4188009.000 ps,
#
##############################"
#input ./perf_log.csv
set input_file = $1
set idx_lst = `awk -F, '(NR>1){print $1}' $input_file| sort -u`
echo "ip, min_time, max_time, aveg_time "
foreach idx ($idx_lst)
set idx_pro_time_lst = `grep -w $idx $input_file | sed 's/.000 ps//g' | awk -F, '{print $6}' | sort `
set sum = 0
foreach pro_time ($idx_pro_time_lst)
@ sum += $pro_time
end
set num_of_cmd = $#idx_pro_time_lst
@ aveg = ($sum / $num_of_cmd)
# echo $idx_pro_time_lst
# echo $sum
# echo $num_of_cmd
# echo $aveg
# echo $idx_pro_time_lst[$#idx_pro_time_lst]
echo "$idx, $idx_pro_time_lst[1], $idx_pro_time_lst[$#idx_pro_time_lst], $aveg"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment