Skip to content

Instantly share code, notes, and snippets.

@videlalvaro
Created January 7, 2010 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlalvaro/271034 to your computer and use it in GitHub Desktop.
Save videlalvaro/271034 to your computer and use it in GitHub Desktop.
#/bin/sh
# run inside a symfony project:
# ./extractinfo.sh log/frontend_dev.log 'execute(Query|Update|Insert)' | sort -n
# will return the number of queries per request
# in symfony 1.2+ you can try something like:
# ./extractinfo.sh log/frontend_dev.log 'sfPropelLogger'
# you can modify the second parameter to extract the required information and also point
# the script to a different symfony log file
# the output will be how many matches of the second parameter occurred inside each symfony request
awk -v info="$2" '
/(M|m)atch route/ {
requests++;
route = $9;
}
$0 ~ info {
result[requests SUBSEP route]++;
}
END {
print info
for(combined in result){
split(combined, separate, SUBSEP);
printf("%d %s\n", result[combined], separate[2]);
}
}
' $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment