`

分析耗时sed & awk

阅读更多

#!/bin/bash

function summary() {
 awk '
    BEGIN { FS="=" }
    {
      if(method[$2]!=0)
      {
       method[$2]=method[$2]+$1;
      }
      else
      {
       method[$2]=$1;
      }
      count[$2]++;
    }
    END {
      for(m in method)
      {
       printf "%f\t%d\t%s\n", method[m]/count[m]/1000.0, count[m], "&"m;
      }
    }
 '
}

#1.find the time and method where time > 1
#2.summary the ave time and count method
#3.sort the result
#4.title
sed -n '/^[^0-9]/s/.*\[\([1-9\,]*\,[0-9]*\)ms.* - \(.*\)/\1=\2/p' $1 \
 | sed 's/\,//' \
 | sed 's/\(.*\=\).*\(.*HSF Service\).\(\$.* \).*\(\$.* \).*/\1\2 \3-> \4/' \
 | summary \
 | sort -t\| -k1 -nr \

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics