misc: add benchmark scripts
This commit is contained in:
parent
a1392cd0e1
commit
07c1f008bc
69
misc/benchmark.rc
Normal file
69
misc/benchmark.rc
Normal file
@ -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, " %"
|
||||||
|
}
|
||||||
|
'
|
31
misc/bmprepare.rc
Normal file
31
misc/bmprepare.rc
Normal file
@ -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
|
@ -12,6 +12,14 @@ diff: ,,c
|
|||||||
|
|
||||||
orig-c-src/markdown_parser.leg: orig-c-src
|
orig-c-src/markdown_parser.leg: orig-c-src
|
||||||
|
|
||||||
|
|
||||||
|
bmprepare:
|
||||||
|
rc ./misc/bmprepare.rc
|
||||||
|
|
||||||
|
benchmark: m ,,pmd ,,prevmd
|
||||||
|
rc ./misc/benchmark.rc
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# pprof
|
# pprof
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user