changeset 16:dbaa8a943271 default tip

merge
author ju
date Thu, 05 Jul 2007 18:13:01 +0200
parents 449b0fc9f764 (current diff) fe4ccf810364 (diff)
children
files cpp_vs_sh.txt graph2.sh
diffstat 6 files changed, 194 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Thu Jul 05 18:13:01 2007 +0200
@@ -0,0 +1,5 @@
+syntax: glob
+*~
+*.swp
+*.png
+*.jpg
--- a/cpp_vs_sh.txt	Thu Jul 05 18:08:31 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-SLOCCOUNT
-
-cpp:            125
-sh:              33
-
-
-
-
-SIZE
-
-14K     graph*
-1.2K    graph2.sh*
-
-
-
-
-PERFORMANCE
-
-$ time ./graph input.txt > graph1.dot
-
-real    0m0.074s
-user    0m0.044s
-sys     0m0.008s
-
-$ time ./graph2.sh input.txt > graph2.dot
-
-real    0m38.405s
-user    0m13.861s
-sys     0m23.349s
--- a/graph2.sh	Thu Jul 05 18:08:31 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#!/bin/bash
-# 
-# Autor: Julian Forster (www.ProgMaschine.de.vu)
-# Autor: markus schnalke (prog.marmaro.de)
-#
-
-
-if [ $# -eq 1 ]; then
-  if [ $1 = '--version' ] ; then
-    echo 'Buddylistgrapher (shell)'
-    echo '========================'
-    echo 'version 0.2'
-    echo
-    echo 'by Julian Forster (http://progmaschine.de.vu)'
-    echo 'and Markus Schnalke (http://prog.marmaro.de)'
-    exit 0
-  elif [ $1 = '--help' ] ; then
-    echo 'Buddylistgrapher (shell)'
-    echo '========================'
-    echo
-    echo "usage: $0 <input.txt>"
-    echo
-    echo "The grapher generates output to stdout."
-    echo "This output is the input for the graphviz tools."
-    echo
-    echo "You can use it like this:"
-    echo "$0 input.txt | dot -Tpng > pic.png"
-    echo
-    echo "ToDo:"
-    echo "The program was written for one specific kind of input data,"
-    echo "so there is still some work to do to use it for general input."
-    exit 0
-  else
-
-    file=/tmp/`basename $0`-$$
-    file2=/tmp/`basename $0`-$$-2
-
-    # extract all needed lines
-    grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
-
-
-    # collect all profil names (we only want them as nodes)
-    cat $file | while read line ; do
-      echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
-    done
-    echo >> $file2
-
-
-    # output
-    echo "digraph G {"
-    
-    cat $file | while read line ; do
-      if [ -n "`echo $line | grep "Profil von:"`" ] ; then
-        name=$(echo $line |  awk '{ print $3 }')
-      else
-        buddy=$(echo $line |  awk '{ print $3 }')
-        if [ -n "`grep -F " $buddy " $file2`" ] ; then
-          echo "  \"$name\" -> \"$buddy\";"
-        fi
-      fi    
-    done
-
-    echo "}"
-
-    rm $file $file2
-    exit 0
-
-  fi
-else
-    echo "usage: $0 <input.txt>"
-    exit 1
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graph_sed.sh	Thu Jul 05 18:13:01 2007 +0200
@@ -0,0 +1,75 @@
+#!/bin/bash
+# 
+# Autor: markus schnalke (prog.marmaro.de)
+# Autor: Julian Forster (www.ProgMaschine.de.vu)
+#
+
+
+if [ $# -eq 1 ]; then
+  if [ $1 = '--version' ] ; then
+    echo 'Buddylistgrapher (sed)'
+    echo '======================'
+    echo 'version 0.1'
+    echo
+    echo 'by Julian Forster (http://progmaschine.de.vu)'
+    echo 'and Markus Schnalke (http://prog.marmaro.de)'
+    exit 0
+  elif [ $1 = '--help' ] ; then
+    echo 'Buddylistgrapher (sed)'
+    echo '======================'
+    echo
+    echo "usage: $0 <input.txt>"
+    echo
+    echo "The grapher generates output to stdout."
+    echo "This output is the input for the graphviz tools."
+    echo
+    echo "You can use it like this:"
+    echo "$0 input.txt | dot -Tpng > pic.png"
+    echo
+    echo "ToDo:"
+    echo "The program was written for one specific kind of input data,"
+    echo "so there is still some work to do to use it for general input."
+    exit 0
+  else
+
+    file=/tmp/`basename $0`-$$
+    file2=/tmp/`basename $0`-$$-2
+
+
+    # sed
+    sed -n -e " 
+      /^Profil/{
+        s/Profil von: \(.\+\)/\"\1\";/
+        w $file
+        s/;$//
+        h
+        #p
+      }
+
+
+      /^Nachricht/{
+        G
+        s/ - [-0-9]\+//
+        s/Nachricht schreiben \(.\+\)\n/\"\1\" /
+        s/\"\(.\+\)\" \"\(.\+\)\"/  \"\2\" -> \"\1\";/
+
+        # write out
+        #p
+        w $file2
+      }
+    " $1
+
+    # output
+    echo "digraph G {"
+    grep -f $file $file2
+    echo "}"
+
+    # cleanup
+    rm $file $file2
+    exit 0
+
+  fi
+else
+    echo "usage: $0 <input.txt>"
+    exit 1
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graph_sh.sh	Thu Jul 05 18:13:01 2007 +0200
@@ -0,0 +1,72 @@
+#!/bin/bash
+# 
+# Autor: Julian Forster (www.ProgMaschine.de.vu)
+# Autor: markus schnalke (prog.marmaro.de)
+#
+
+
+if [ $# -eq 1 ]; then
+  if [ $1 = '--version' ] ; then
+    echo 'Buddylistgrapher (shell)'
+    echo '========================'
+    echo 'version 0.2'
+    echo
+    echo 'by Julian Forster (http://progmaschine.de.vu)'
+    echo 'and Markus Schnalke (http://prog.marmaro.de)'
+    exit 0
+  elif [ $1 = '--help' ] ; then
+    echo 'Buddylistgrapher (shell)'
+    echo '========================'
+    echo
+    echo "usage: $0 <input.txt>"
+    echo
+    echo "The grapher generates output to stdout."
+    echo "This output is the input for the graphviz tools."
+    echo
+    echo "You can use it like this:"
+    echo "$0 input.txt | dot -Tpng > pic.png"
+    echo
+    echo "ToDo:"
+    echo "The program was written for one specific kind of input data,"
+    echo "so there is still some work to do to use it for general input."
+    exit 0
+  else
+
+    file=/tmp/`basename $0`-$$
+    file2=/tmp/`basename $0`-$$-2
+
+    # extract all needed lines
+    grep -e "Profil von:" -e "Nachricht schreiben" $1 > $file
+
+
+    # collect all profil names (we only want them as nodes)
+    cat $file | while read line ; do
+      echo -n "`echo $line | grep "Profil von:" | awk '{print " " $3 " "}'`" >> $file2
+    done
+    echo >> $file2
+
+
+    # output
+    echo "digraph G {"
+    
+    cat $file | while read line ; do
+      if [ -n "`echo $line | grep "Profil von:"`" ] ; then
+        name=$(echo $line |  awk '{ print $3 }')
+      else
+        buddy=$(echo $line |  awk '{ print $3 }')
+        if [ -n "`grep -F " $buddy " $file2`" ] ; then
+          echo "  \"$name\" -> \"$buddy\";"
+        fi
+      fi    
+    done
+
+    echo "}"
+
+    rm $file $file2
+    exit 0
+
+  fi
+else
+    echo "usage: $0 <input.txt>"
+    exit 1
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/performance.txt	Thu Jul 05 18:13:01 2007 +0200
@@ -0,0 +1,42 @@
+SLOCCOUNT
+
+cpp:            125
+sh:              52
+sed:             52
+
+
+
+
+SIZE
+
+14K     graph*       (cpp)
+1.8K    graph2.sh*   (sh)
+1.8K    graph3.sh*   (sed)
+
+
+
+
+PERFORMANCE
+
+C++
+
+$ time ./graph input.txt > output.txt
+  real    0m0.041s
+  user    0m0.040s
+  sys     0m0.000s
+
+
+sh
+
+$ time ./graph2.sh input.txt > output.txt
+  real    0m20.611s
+  user    0m5.332s
+  sys     0m14.357s
+
+
+sed
+
+$ time ./graph3.sh input.txt > output.txt
+  real    0m0.195s
+  user    0m0.168s
+  sys     0m0.016s