diff options
Diffstat (limited to 'zsh/.local/bin/sort_timings.zsh')
| -rwxr-xr-x | zsh/.local/bin/sort_timings.zsh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zsh/.local/bin/sort_timings.zsh b/zsh/.local/bin/sort_timings.zsh new file mode 100755 index 0000000..93b00e0 --- /dev/null +++ b/zsh/.local/bin/sort_timings.zsh @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +typeset -a lines +typeset -i prev_time=0 +typeset prev_command + +while read line; do + if [[ $line =~ '^.*\+([0-9]{10})\.([0-9]{6})[0-9]* (.+)' ]]; then + integer this_time=$match[1]$match[2] + + if [[ $prev_time -gt 0 ]]; then + time_difference=$(( $this_time - $prev_time )) + lines+="$time_difference $prev_command" + fi + + prev_time=$this_time + + local this_command=$match[3] + if [[ ${#this_command} -le 80 ]]; then + prev_command=$this_command + else + prev_command="${this_command:0:180}..." + fi + fi +done < ${1:-/dev/stdin} + +print -l ${(@On)lines} |
