Skip to content

Commit

Permalink
Simple benchmark application for uulib
Browse files Browse the repository at this point in the history
(using criterion and progression ~ a pain to install on GHC 7)

See results in directory "results".
  • Loading branch information
ariem committed Jan 25, 2011
1 parent 687518f commit 171eb06
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 0 deletions.
4 changes: 4 additions & 0 deletions benchmark/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cabal configure --enable-executable-profiling
cabal build
./dist/build/uulib-benchmark/uulib-benchmark +RTS -A2M -H512M -k64k -RTS -- --samples=20
./dist/build/uulib-benchmark/uulib-benchmark +RTS -A2M -H512M -k64k -prof -RTS -- --samples=20
10 changes: 10 additions & 0 deletions benchmark/results/bench-eval.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Name,Mean,MeanLB,MeanUB,Stddev,StddevLB,StddevUB
"uulib/20",2.272895048625728e-3,2.0507604584768017e-3,2.4836232965861366e-3,5.278201461148121e-4,4.5514023129804217e-4,5.467334094654981e-4
"uulib/50",2.8149618977539544e-3,2.8022356438205777e-3,2.8311412474413184e-3,3.340375346613801e-5,2.6650886940154937e-5,4.449787822345967e-5
"uulib/100",5.650665928286219e-3,5.6265761150537975e-3,5.707702804964688e-3,8.150044473720025e-5,2.928338959281505e-5,1.4374500804930444e-4
"uulib/400",2.4555516663595796e-2,2.2761458579107885e-2,2.842167657951987e-2,5.647802952734029e-3,1.429735506771355e-3,8.60713615928108e-3
"uulib/800",4.567136848649335e-2,4.522726619920086e-2,4.696242893418621e-2,1.6257369033951868e-3,6.018242937947777e-4,3.15214252396052e-3
"uulib/1000",5.69418677159245e-2,5.649409378251385e-2,5.799845541199995e-2,1.5110212412057947e-3,7.533279955469046e-4,2.777298580904198e-3
"uulib/1500",8.480877960404706e-2,8.426467264375043e-2,8.646814907273602e-2,2.027999221425985e-3,7.026229926476399e-4,3.94404516067726e-3
"uulib/2000",0.11346645439347579,0.11278324211320233,0.11472545946320843,2.1170423039290945e-3,1.0078249601555018e-3,3.13890831215934e-3
"uulib/3000",0.17146449173173264,0.16946640098771407,0.1748495587178166,5.93677523694127e-3,3.810446854725549e-3,8.578750101347801e-3
10 changes: 10 additions & 0 deletions benchmark/results/bench-parseio.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Name,Mean,MeanLB,MeanUB,Stddev,StddevLB,StddevUB
"uulib/20",2.8634536263346675e-3,2.6013636586070064e-3,3.0734443661570555e-3,5.531830923001629e-4,4.579906981058414e-4,5.956727535465023e-4
"uulib/50",4.053612549602985e-3,4.0164311721920965e-3,4.09210324237744e-3,8.896134799857259e-5,7.038690314958943e-5,1.15668490865021e-4
"uulib/100",8.748165765404702e-3,8.666197457909584e-3,8.859837054212888e-3,2.224999570682226e-4,1.5987528368054175e-4,3.3377822617027474e-4
"uulib/400",3.70622634857893e-2,3.679455518424511e-2,3.741004466712475e-2,7.122312919320258e-4,5.313194573729724e-4,1.0144004516899085e-3
"uulib/800",2.638384413716197,7.91595816582441e-2,12.871493828293682,11.435822160445483,1.2224975075125852e-2,22.721654708824257
"uulib/1000",8.211678075787427,9.207389354407787e-2,40.689727723595496,36.31135014728181,8.534317547810496e-4,72.14342908223881
"uulib/1500",16.264785635468364,0.1464041233032942,74.54432026147546,63.03985581208665,8.584953269764554e-3,124.86469200376835
"uulib/2000",141.543726003167,15.766105341908332,636.1333431601495,527.0653985752955,48.69870431436039,1047.175820693637
"uulib/3000",
10 changes: 10 additions & 0 deletions benchmark/results/bench-prfl-eval.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Name,Mean,MeanLB,MeanUB,Stddev,StddevLB,StddevUB
"uulib/20",3.7805317029107484e-3,3.42732120071009e-3,4.1411133128486256e-3,8.892275213376866e-4,8.525908857973594e-4,9.116075583787259e-4
"uulib/50",6.604746177973347e-3,6.585660770716267e-3,6.630263777896616e-3,5.1556788231246826e-5,3.7409753356753845e-5,6.595546086327632e-5
"uulib/100",1.3130008633359927e-2,1.3092974280739484e-2,1.3169768905068097e-2,9.003535178703916e-5,7.128227227385347e-5,1.1629333597712591e-4
"uulib/400",5.2414499090387395e-2,5.2186046407892275e-2,5.288747386760907e-2,7.419658213314667e-4,3.7294745366847116e-4,1.3465457532144608e-3
"uulib/800",0.10499824123211102,0.1044729454977055,0.10646246509380537,1.9128177831048605e-3,7.166166037433508e-4,3.6940761692132546e-3
"uulib/1000",0.1308173401815434,0.13008194999523356,0.13248568610973555,2.4537668680879535e-3,1.2441441243538729e-3,4.384579498181594e-3
"uulib/1500",0.19620874957866863,0.19466638402767378,0.19858140783138473,4.4086089113490635e-3,2.9382793260000497e-3,6.528468306016297e-3
"uulib/2000",0.2628987653715153,0.261148749159052,0.2656307681066532,5.058779837637365e-3,3.2050829045080975e-3,6.492978558628257e-3
"uulib/3000",0.39777316884823033,0.39348784522838787,0.40368189649410435,1.1661619837417215e-2,8.67313036101857e-3,1.5055110476604593e-2
10 changes: 10 additions & 0 deletions benchmark/results/bench-prfl-parseio.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Name,Mean,MeanLB,MeanUB,Stddev,StddevLB,StddevUB
"uulib/20",4.046170180888167e-3,3.726906841845503e-3,4.462247357618005e-3,8.518538661270488e-4,6.202600558520674e-4,9.754693773391266e-4
"uulib/50",8.291822113635995e-3,8.248367943408946e-3,8.34019485914991e-3,1.0794118131653912e-4,8.433310372080122e-5,1.4330492840114646e-4
"uulib/100",1.7700395051046966e-2,1.7185347341899835e-2,1.956189181745525e-2,2.0414275993242657e-3,2.837303855064425e-4,4.018535526729534e-3
"uulib/400",8.348124344171513e-2,7.721726019205082e-2,9.385962803186404e-2,1.8448707580525806e-2,1.1381404367209282e-2,2.5467484077480753e-2
"uulib/800",0.1551623256904029,0.1537981899482154,0.15693822223962775,3.617498134006265e-3,2.7307425818686787e-3,4.47189929098625e-3
"uulib/1000",0.19972309191049564,0.19849288780511848,0.20173932630838387,3.635376831989681e-3,2.1426232397000135e-3,5.169283347939957e-3
"uulib/1500",0.2904823334914588,0.28972281534494393,0.29104999620737065,1.538374255609886e-3,1.0904715151150556e-3,2.100320857398588e-3
"uulib/2000",0.4049024375182532,0.3985385330420875,0.4171884687644385,2.0060659701762035e-2,1.1646989314246374e-2,3.391444434980294e-2
"uulib/3000",0.5666849525672338,0.5652930529815099,0.5684745105010414,3.687687958438311e-3,2.7468365853147185e-3,4.9383471377965945e-3
45 changes: 45 additions & 0 deletions benchmark/src/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- | Some benchmarks for UULIB.
module Main(main) where

import UU.Parsing
import UU.Parsing.Derived
import UU.Parsing.CharParser
import UU.Parsing.Interface
import UU.Parsing.MachineInterface

import Control.DeepSeq
import Criterion.Types
import Progression.Main

-- | 26 Choices
uulibP :: Parser Char String
uulibP = pList $ pAny pSym ['a'..'z']

input :: Int -> String
input s = concat $ replicate s difficultString

difficultString :: String
difficultString = "abcdefadsjkhdasjkdasjhkdsakjdsajkdsafklfddsfajklyrrtttryytuuyttyuuytuytyuuyiuyiiuyfuyfdfsajksdfakldlsdfklsljkasxcvmdfsndfsjkldfskjdfsjkghi"

mkBench :: Int -> (String, IO ())
mkBench s = (nm,m) where
nm = show s
m = do let str = input s
deepseq str (return ())
a <- getResult (touch <$> uulibP) str
seq a (return ())

touch :: [a] -> ()
touch [] = ()
touch (x:xs) = seq x (touch xs)

getResult :: Parser Char a -> String -> IO a
getResult p str =
return $ unpack $ evalSteps $ parse p str where unpack (Pair v _) = v
-- parseIO p str

sizes :: [Int]
sizes = [20,50,100,400,800,1000,1500,2000,3000]

main :: IO ()
main = defaultMain $ bgroup "uulib" $ map (uncurry bench) $ map mkBench sizes
18 changes: 18 additions & 0 deletions benchmark/uulib-benchmark.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cabal-version: >= 1.8
build-type: Simple
name: uulib-benchmark
version: 1.0
license: LGPL
maintainer: Arie Middelkoop <ariem@cs.uu.nl>
homepage: http://www.cs.uu.nl/wiki/HUT/WebHome
description: Benchmark program for UULIB
category: Parsing
stability: Experimental
copyright: Arie Middelkoop

executable uulib-benchmark
Main-is: Main.hs
build-depends: base >= 4, base < 5, uulib >= 0.9.13
build-depends: progression >= 0.4, criterion >= 0.5, deepseq >= 1.1.0.2
hs-source-dirs: src
ghc-options: -rtsopts

0 comments on commit 171eb06

Please sign in to comment.