Commit bcd8589c authored by Mike Ledger's avatar Mike Ledger

fix tests

parent c7d9945c
import qualified GHC.HeapView
:def! setPrintHeapDepth \x -> return $ ":def! printHeap \\x -> return $ \"GHC.HeapView.buildHeapGraph (" ++ x ++ ") () (GHC.HeapView.asBox (\" ++ x ++ \")) >>= putStrLn . GHC.HeapView.ppHeapGraph\""
:setPrintHeapDepth 1000
......@@ -8,6 +8,7 @@ import qualified Data.RadixTree as R
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Vector as V
import GHC.Compact
import Text.QuasiText
parseNaiive :: [Text] -> A.Parser Text
......@@ -19,9 +20,15 @@ main = defaultMain
~(src, radix, radix2, tests) ->
bgroup "attoparsec"
[ bench "radix" $
V.foldl' (\() t -> rnf $ A.parseOnly (R.parse radix) t) () `nf` tests
V.foldl' (\() t -> rnf $ A.parseOnly (R.parse const radix) t) () `nf` tests
, bench "radix compressed" $
V.foldl' (\() t -> rnf $ A.parseOnly (R.parse radix2) t) () `nf` tests
V.foldl' (\() t -> rnf $ A.parseOnly (R.parse const radix2) t) () `nf` tests
, env (getCompact <$> compact radix2) $ \compactR ->
bench "radix compressed compact" $
V.foldl' (\() t -> rnf $ A.parseOnly (R.parse const radix2) t) () `nf` tests
, bench "naiive" $
V.foldl' (\() t -> rnf $ A.parseOnly (parseNaiive src) t) () `nf` tests
]
......@@ -37,14 +44,14 @@ tests0 = V.fromList $! T.lines
\long thing that doesn't parse\n\
\z"
sourceRadixCompressed :: R.CompressedRadixTree
sourceRadixCompressed :: R.CompressedRadixTree ()
sourceRadixCompressed =
case R.compressBy (T.concat source) sourceRadix of
Just ct -> ct
Nothing -> error "could not compress source"
sourceRadix :: R.RadixTree
sourceRadix = R.fromFoldable source
sourceRadix :: R.RadixTree ()
sourceRadix = R.fromFoldable_ source
source :: [Text]
source = T.lines [embed|
......@@ -929,4 +936,3 @@ yaw
year
years
yellow|]
......@@ -40,14 +40,14 @@ tests0 = V.fromList $! T.lines
\long thing that doesn't parse\n\
\z"
sourceRadixCompressed :: R.CompressedRadixTree
sourceRadixCompressed :: R.CompressedRadixTree ()
sourceRadixCompressed =
case R.compressBy (T.concat source) sourceRadix of
Just ct -> ct
Nothing -> error "could not compress source"
sourceRadix :: R.RadixTree
sourceRadix = R.fromFoldable source
sourceRadix :: R.RadixTree ()
sourceRadix = R.fromFoldable_ source
source :: [Text]
source = T.lines [embed|
......@@ -932,4 +932,3 @@ yaw
year
years
yellow|]
{ nixpkgs ? import <nixpkgs> {}, extra ? {}, drv ? {} }:
{ nixpkgs ? import <nixpkgs> {}, haskellPackages ? nixpkgs.haskellPackages, extra ? {}, drv ? {} }:
let
path = ./.;
name = builtins.baseNameOf path;
......@@ -10,7 +10,7 @@ in
(if builtins.isFunction extra then extra nixpkgs else extra))
(drv0: (drv0 // {
doCheck = true;
doBenchmark = false;
doBenchmark = true;
doHaddock = false;
doCoverage = false;
enableLibraryProfiling = false;
......
......@@ -61,11 +61,7 @@ test-suite radixtree-test
benchmark radixtree-parsing
type: exitcode-stdio-1.0
main-is: Parsing.hs
other-modules:
Search
Paths_radixtree
hs-source-dirs:
bench
hs-source-dirs: bench
ghc-options: -O2
build-depends:
attoparsec
......@@ -75,16 +71,14 @@ benchmark radixtree-parsing
, radixtree
, text
, vector
, QuasiText
, ghc-compact
default-language: Haskell2010
benchmark radixtree-search
type: exitcode-stdio-1.0
main-is: Search.hs
other-modules:
Parsing
Paths_radixtree
hs-source-dirs:
bench
hs-source-dirs: bench
ghc-options: -O2
build-depends:
attoparsec
......@@ -94,4 +88,5 @@ benchmark radixtree-search
, radixtree
, text
, vector
, QuasiText
default-language: Haskell2010
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment