buddylistgrapher
changeset 16:dbaa8a943271 tip
merge
author | ju |
---|---|
date | Thu, 05 Jul 2007 18:13:01 +0200 |
parents | 449b0fc9f764 fe4ccf810364 |
children | |
files | cpp_vs_sh.txt graph2.sh |
diffstat | 6 files changed, 194 insertions(+), 101 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Thu Jul 05 18:13:01 2007 +0200 1.3 @@ -0,0 +1,5 @@ 1.4 +syntax: glob 1.5 +*~ 1.6 +*.swp 1.7 +*.png 1.8 +*.jpg
2.1 --- a/cpp_vs_sh.txt Thu Jul 05 18:08:31 2007 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,29 +0,0 @@ 2.4 -SLOCCOUNT 2.5 - 2.6 -cpp: 125 2.7 -sh: 33 2.8 - 2.9 - 2.10 - 2.11 - 2.12 -SIZE 2.13 - 2.14 -14K graph* 2.15 -1.2K graph2.sh* 2.16 - 2.17 - 2.18 - 2.19 - 2.20 -PERFORMANCE 2.21 - 2.22 -$ time ./graph input.txt > graph1.dot 2.23 - 2.24 -real 0m0.074s 2.25 -user 0m0.044s 2.26 -sys 0m0.008s 2.27 - 2.28 -$ time ./graph2.sh input.txt > graph2.dot 2.29 - 2.30 -real 0m38.405s 2.31 -user 0m13.861s 2.32 -sys 0m23.349s
3.1 --- a/graph2.sh Thu Jul 05 18:08:31 2007 +0200 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,72 +0,0 @@ 3.4 -#!/bin/bash 3.5 -# 3.6 -# Autor: Julian Forster (www.ProgMaschine.de.vu) 3.7 -# Autor: markus schnalke (prog.marmaro.de) 3.8 -# 3.9 - 3.10 - 3.11 -if [ $# -eq 1 ]; then 3.12 - if [ $1 = '--version' ] ; then 3.13 - echo 'Buddylistgrapher (shell)' 3.14 - echo '========================' 3.15 - echo 'version 0.2' 3.16 - echo 3.17 - echo 'by Julian Forster (http://progmaschine.de.vu)' 3.18 - echo 'and Markus Schnalke (http://prog.marmaro.de)' 3.19 - exit 0 3.20 - elif [ $1 = '--help' ] ; then 3.21 - echo 'Buddylistgrapher (shell)' 3.22 - echo '========================' 3.23 - echo 3.24 - echo "usage: $0 <input.txt>" 3.25 - echo 3.26 - echo "The grapher generates output to stdout." 3.27 - echo "This output is the input for the graphviz tools." 3.28 - echo 3.29 - echo "You can use it like this:" 3.30 - echo "$0 input.txt | dot -Tpng > pic.png" 3.31 - echo 3.32 - echo "ToDo:" 3.33 - echo "The program was written for one specific kind of input data," 3.34 - echo "so there is still some work to do to use it for general input." 3.35 - exit 0 3.36 - else 3.37 - 3.38 - file=/tmp/`basename $0`-$$ 3.39 - file2=/tmp/`basename $0`-$$-2 3.40 - 3.41 - # extract all needed lines 3.42 - grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file 3.43 - 3.44 - 3.45 - # collect all profil names (we only want them as nodes) 3.46 - cat $file | while read line ; do 3.47 - echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2 3.48 - done 3.49 - echo >> $file2 3.50 - 3.51 - 3.52 - # output 3.53 - echo "digraph G {" 3.54 - 3.55 - cat $file | while read line ; do 3.56 - if [ -n "`echo $line | grep "Profil von:"`" ] ; then 3.57 - name=$(echo $line | awk '{ print $3 }') 3.58 - else 3.59 - buddy=$(echo $line | awk '{ print $3 }') 3.60 - if [ -n "`grep -F " $buddy " $file2`" ] ; then 3.61 - echo " \"$name\" -> \"$buddy\";" 3.62 - fi 3.63 - fi 3.64 - done 3.65 - 3.66 - echo "}" 3.67 - 3.68 - rm $file $file2 3.69 - exit 0 3.70 - 3.71 - fi 3.72 -else 3.73 - echo "usage: $0 <input.txt>" 3.74 - exit 1 3.75 -fi
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/graph_sed.sh Thu Jul 05 18:13:01 2007 +0200 4.3 @@ -0,0 +1,75 @@ 4.4 +#!/bin/bash 4.5 +# 4.6 +# Autor: markus schnalke (prog.marmaro.de) 4.7 +# Autor: Julian Forster (www.ProgMaschine.de.vu) 4.8 +# 4.9 + 4.10 + 4.11 +if [ $# -eq 1 ]; then 4.12 + if [ $1 = '--version' ] ; then 4.13 + echo 'Buddylistgrapher (sed)' 4.14 + echo '======================' 4.15 + echo 'version 0.1' 4.16 + echo 4.17 + echo 'by Julian Forster (http://progmaschine.de.vu)' 4.18 + echo 'and Markus Schnalke (http://prog.marmaro.de)' 4.19 + exit 0 4.20 + elif [ $1 = '--help' ] ; then 4.21 + echo 'Buddylistgrapher (sed)' 4.22 + echo '======================' 4.23 + echo 4.24 + echo "usage: $0 <input.txt>" 4.25 + echo 4.26 + echo "The grapher generates output to stdout." 4.27 + echo "This output is the input for the graphviz tools." 4.28 + echo 4.29 + echo "You can use it like this:" 4.30 + echo "$0 input.txt | dot -Tpng > pic.png" 4.31 + echo 4.32 + echo "ToDo:" 4.33 + echo "The program was written for one specific kind of input data," 4.34 + echo "so there is still some work to do to use it for general input." 4.35 + exit 0 4.36 + else 4.37 + 4.38 + file=/tmp/`basename $0`-$$ 4.39 + file2=/tmp/`basename $0`-$$-2 4.40 + 4.41 + 4.42 + # sed 4.43 + sed -n -e " 4.44 + /^Profil/{ 4.45 + s/Profil von: \(.\+\)/\"\1\";/ 4.46 + w $file 4.47 + s/;$// 4.48 + h 4.49 + #p 4.50 + } 4.51 + 4.52 + 4.53 + /^Nachricht/{ 4.54 + G 4.55 + s/ - [-0-9]\+// 4.56 + s/Nachricht schreiben \(.\+\)\n/\"\1\" / 4.57 + s/\"\(.\+\)\" \"\(.\+\)\"/ \"\2\" -> \"\1\";/ 4.58 + 4.59 + # write out 4.60 + #p 4.61 + w $file2 4.62 + } 4.63 + " $1 4.64 + 4.65 + # output 4.66 + echo "digraph G {" 4.67 + grep -f $file $file2 4.68 + echo "}" 4.69 + 4.70 + # cleanup 4.71 + rm $file $file2 4.72 + exit 0 4.73 + 4.74 + fi 4.75 +else 4.76 + echo "usage: $0 <input.txt>" 4.77 + exit 1 4.78 +fi
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/graph_sh.sh Thu Jul 05 18:13:01 2007 +0200 5.3 @@ -0,0 +1,72 @@ 5.4 +#!/bin/bash 5.5 +# 5.6 +# Autor: Julian Forster (www.ProgMaschine.de.vu) 5.7 +# Autor: markus schnalke (prog.marmaro.de) 5.8 +# 5.9 + 5.10 + 5.11 +if [ $# -eq 1 ]; then 5.12 + if [ $1 = '--version' ] ; then 5.13 + echo 'Buddylistgrapher (shell)' 5.14 + echo '========================' 5.15 + echo 'version 0.2' 5.16 + echo 5.17 + echo 'by Julian Forster (http://progmaschine.de.vu)' 5.18 + echo 'and Markus Schnalke (http://prog.marmaro.de)' 5.19 + exit 0 5.20 + elif [ $1 = '--help' ] ; then 5.21 + echo 'Buddylistgrapher (shell)' 5.22 + echo '========================' 5.23 + echo 5.24 + echo "usage: $0 <input.txt>" 5.25 + echo 5.26 + echo "The grapher generates output to stdout." 5.27 + echo "This output is the input for the graphviz tools." 5.28 + echo 5.29 + echo "You can use it like this:" 5.30 + echo "$0 input.txt | dot -Tpng > pic.png" 5.31 + echo 5.32 + echo "ToDo:" 5.33 + echo "The program was written for one specific kind of input data," 5.34 + echo "so there is still some work to do to use it for general input." 5.35 + exit 0 5.36 + else 5.37 + 5.38 + file=/tmp/`basename $0`-$$ 5.39 + file2=/tmp/`basename $0`-$$-2 5.40 + 5.41 + # extract all needed lines 5.42 + grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file 5.43 + 5.44 + 5.45 + # collect all profil names (we only want them as nodes) 5.46 + cat $file | while read line ; do 5.47 + echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2 5.48 + done 5.49 + echo >> $file2 5.50 + 5.51 + 5.52 + # output 5.53 + echo "digraph G {" 5.54 + 5.55 + cat $file | while read line ; do 5.56 + if [ -n "`echo $line | grep "Profil von:"`" ] ; then 5.57 + name=$(echo $line | awk '{ print $3 }') 5.58 + else 5.59 + buddy=$(echo $line | awk '{ print $3 }') 5.60 + if [ -n "`grep -F " $buddy " $file2`" ] ; then 5.61 + echo " \"$name\" -> \"$buddy\";" 5.62 + fi 5.63 + fi 5.64 + done 5.65 + 5.66 + echo "}" 5.67 + 5.68 + rm $file $file2 5.69 + exit 0 5.70 + 5.71 + fi 5.72 +else 5.73 + echo "usage: $0 <input.txt>" 5.74 + exit 1 5.75 +fi
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/performance.txt Thu Jul 05 18:13:01 2007 +0200 6.3 @@ -0,0 +1,42 @@ 6.4 +SLOCCOUNT 6.5 + 6.6 +cpp: 125 6.7 +sh: 52 6.8 +sed: 52 6.9 + 6.10 + 6.11 + 6.12 + 6.13 +SIZE 6.14 + 6.15 +14K graph* (cpp) 6.16 +1.8K graph2.sh* (sh) 6.17 +1.8K graph3.sh* (sed) 6.18 + 6.19 + 6.20 + 6.21 + 6.22 +PERFORMANCE 6.23 + 6.24 +C++ 6.25 + 6.26 +$ time ./graph input.txt > output.txt 6.27 + real 0m0.041s 6.28 + user 0m0.040s 6.29 + sys 0m0.000s 6.30 + 6.31 + 6.32 +sh 6.33 + 6.34 +$ time ./graph2.sh input.txt > output.txt 6.35 + real 0m20.611s 6.36 + user 0m5.332s 6.37 + sys 0m14.357s 6.38 + 6.39 + 6.40 +sed 6.41 + 6.42 +$ time ./graph3.sh input.txt > output.txt 6.43 + real 0m0.195s 6.44 + user 0m0.168s 6.45 + sys 0m0.016s