Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/perf-testing #14

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions benchmarks/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{-# LANGUAGE StandaloneDeriving, DeriveAnyClass, DeriveGeneric #-}
module Main where

import Gauge (defaultMain, bench, nf)
import Text.Gigaparsec (Parsec, Result(..), parse, atomic, (<|>))
import Text.Gigaparsec.Char (string)
import Control.DeepSeq
import GHC.Generics

p :: Parsec String
p = atomic (string "hello wold") <|> atomic (string "hi") <|> string "hello world"

deriving instance Generic (Result a)
deriving instance NFData a => NFData (Result a)

main :: IO ()
main = defaultMain [
bench "consumption" $ nf (parse p) "hello world"
]
22 changes: 21 additions & 1 deletion gigaparsec.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,29 @@ test-suite gigaparsec-test
containers >= 0.6 && < 0.7,
tasty >=1.1 && <1.6,
--tasty-expected-failure,
tasty-hunit >=0.9 && <0.11
tasty-hunit >=0.9 && <0.11,
--TODO: property based testing will be useful when we optimise combinators
-- to test against their base implementations
--tasty-quickcheck
--TODO: performance testing with tasty-bench?
--tasty-bench
-- we'd need to keep the basefile files somewhere, cache in CI or keep in repo?

benchmark perf-test
import: warnings, extensions, base

type: exitcode-stdio-1.0

default-extensions: OverloadedStrings, TypeOperators, BlockArguments, GADTs

-- Base language which the package is written in.
default-language: Haskell2010

hs-source-dirs: benchmarks
build-depends:
gigaparsec,
--containers >= 0.6 && < 0.7,
gauge >= 0.1 && < 0.3,
deepseq >= 1.4 && < 1.6

main-is: Main.hs
Loading