Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

misc: add benchmark scripts

  • Loading branch information...
commit 07c1f008bc905520e460c143c2563f133fbdec11 1 parent a1392cd
@knieriem authored
Showing with 108 additions and 0 deletions.
  1. +69 −0 misc/benchmark.rc
  2. +31 −0 misc/bmprepare.rc
  3. +8 −0 misc/devel.mk
View
69 misc/benchmark.rc
@@ -0,0 +1,69 @@
+#!/usr/local/plan9/bin/rc
+
+nrun=20
+
+fn timego{
+ run ./cmd/markdown go
+}
+fn timegoprev{
+ run ./,,prevmd/cmd/markdown goprev
+}
+
+fn timec{
+ run ,,pmd/markdown c
+}
+
+fn run{
+ xtime $1 < m >[2=1] > /tmp/,,out.$2
+}
+
+fn xtime{
+# /usr/bin/time -f '%Uu %Ss %er %MkB %C' $*
+ /usr/bin/time -f '%U %M' $*
+}
+
+fn cmpout{
+ if (! cmp /tmp/,,out.$1 /tmp/,,out.$2) {
+ echo not equal: $1 $2 >[1=2]
+ exit -1
+ }
+}
+
+{
+ start = 1
+ for (i in `{seq 1 $nrun}) {
+ echo `{timec} `{timego} `{timegoprev}
+ if (~ $start 1){
+ cmpout go c
+ cmpout go goprev
+ start = 0
+ }
+ }
+} | awk '
+ BEGIN {
+ pfx = "#"
+ }
+ {
+ tc = $1
+ mc = $2
+ tgo = $3
+ mgo = $4
+ tprev = $5
+ mprev = 46
+ }
+ {
+ print pfx, "c:", tc, "go:" tgo, "frac:", tgo/tc, "go,prev:", tgo/tprev*100, " %", "mem:", mgo/mc
+ }
+ NR < 5 { next }
+ {
+ pfx = ""
+ csum += tc
+ gosum += tgo
+ goprevsum += tprev
+ n++
+ }
+ END {
+ print "SUM"
+ print "c:", csum, "go:", gosum, "n:", n, "frac", gosum/csum, gosum/goprevsum*100, " %"
+ }
+'
View
31 misc/bmprepare.rc
@@ -0,0 +1,31 @@
+#!/usr/local/plan9/bin/rc
+
+flag e +
+
+fn updatetree{ # hg-id dir hg-url make-target
+ if (test -d $2) {
+ cd $2
+ if (! ~ `{hg id -n} $1) {
+ hg update $1
+ make $4
+ }
+ cd ..
+ }
+ if (! test -d $2) {
+ hg clone $3 $2
+ cd $2
+ hg update $1
+ make $4
+ cd ..
+ }
+ ~ 0 0
+}
+
+
+echo '*' prepare original c-based peg-markdown ($portid)
+
+updatetree `{cat portid} ,,pmd git://github.com/jgm/peg-markdown.git ()
+
+echo '*' prepare "previous version" ($previd)
+
+updatetree `{cat previd} ,,prevmd . all
View
8 misc/devel.mk
@@ -12,6 +12,14 @@ diff: ,,c
orig-c-src/markdown_parser.leg: orig-c-src
+
+bmprepare:
+ rc ./misc/bmprepare.rc
+
+benchmark: m ,,pmd ,,prevmd
+ rc ./misc/benchmark.rc
+
+
#
# pprof
#
Please sign in to comment.
Something went wrong with that request. Please try again.