Skip to content

Commit

Permalink
yapb-0.2.3; measure execution time
Browse files Browse the repository at this point in the history
  • Loading branch information
kwanghoon committed Apr 4, 2022
1 parent 8613da8 commit 59c1449
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: yapb
version: 0.2.2
version: 0.2.3
github: "kwanghoon/yapb"
license: BSD3
author: "Kwanghoon Choi"
Expand All @@ -25,6 +25,7 @@ dependencies:
- transformers
- mtl
- deepseq >= 1.4.4.0
- timeit >= 2.0

# --------------------------------------------------
# -- Main library: YAPB (Yet Another Parser Builder)
Expand Down
13 changes: 12 additions & 1 deletion src/parserlib/CommonParserUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ import System.Directory
import Control.Exception
import System.IO.Error hiding (catch)

import System.TimeIt (timeItT)
import Control.Monad.IO.Class(MonadIO(liftIO))
import Text.Printf

-- | Common parser utilities:
-- |
-- | 1. A parser(and lexer) specification interface to the parser generator
Expand Down Expand Up @@ -874,7 +878,7 @@ _handleParseError
Nothing -> \s -> "..."
Just fn -> fn
in
do (candidateListList, emacsDisplay) <- compCandidatesFn ccOption 0 [] state stk
do (candidateListList, emacsDisplay) <- timeItShow (compCandidatesFn ccOption 0 [] state stk)
let colorListList_symbols =
[ filterCandidates candidateList terminalListAfterCursor
| candidateList <- candidateListList ]
Expand Down Expand Up @@ -995,3 +999,10 @@ concatStrList (str:strs) = str ++ " " ++ concatStrList strs
-- debug :: Bool -> String -> a -> a
-- debug flag msg x = if flag then trace msg x else x

--
timeItShow :: (MonadIO m, Show a) => m a -> m a
timeItShow ioa =
do (t,a) <- timeItT ioa
liftIO $ printf ("Time: %6.2f\n") t
return a

4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ extra-deps:
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
#extra-deps:
# - json-0.10
extra-deps:
- timeit-2.0

# Override default flag values for local packages and extra-deps
# flags: {}
Expand Down
9 changes: 8 additions & 1 deletion stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
packages:
- completed:
hackage: timeit-2.0@sha256:35d7c3ce64b458bbb1200320203f21281c975c85acc636a634500601c474fded,1197
pantry-tree:
size: 259
sha256: c37c98f2173d5c1a651483b90163cdb9384a6d76b0adb7dfad58cbc9e9b7be86
original:
hackage: timeit-2.0
snapshots:
- completed:
size: 531674
Expand Down
12 changes: 10 additions & 2 deletions yapb.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: d0b9a77c0d67fbcf2f0f940bd558e929e1fa2e0e1ca4d08e171c07c0244e03ad
-- hash: f77819b422fe4bf504a61917dc5fbf6875bc35d76c7f3ea16707505b9f6134ed

name: yapb
version: 0.2.2
version: 0.2.3
synopsis: Yet Another Parser Builder (YAPB)
description: A programmable LALR(1) parser builder system. Please see the README on GitHub at <https://github.com/kwanghoon/yapb#readme>
category: parser builder
Expand Down Expand Up @@ -73,6 +73,7 @@ library
, network >=3.1.1 && <3.2
, process >=1.6.5 && <1.7
, regex-tdfa >=1.3.1 && <1.4
, timeit >=2.0
, transformers
default-language: Haskell2010

Expand All @@ -96,6 +97,7 @@ executable ambiguous-exe
, hspec
, mtl
, regex-tdfa
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010
Expand All @@ -112,6 +114,7 @@ executable conv-exe
, deepseq >=1.4.4.0
, hspec
, mtl
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010
Expand All @@ -136,6 +139,7 @@ executable error-exe
, hspec
, mtl
, regex-tdfa
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010
Expand All @@ -160,6 +164,7 @@ executable parser-exe
, hspec
, mtl
, regex-tdfa
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010
Expand All @@ -184,6 +189,7 @@ executable syncomp-exe
, hspec
, mtl
, regex-tdfa
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010
Expand All @@ -200,6 +206,7 @@ executable yapb-exe
, deepseq >=1.4.4.0
, hspec
, mtl
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010
Expand All @@ -218,6 +225,7 @@ test-suite yapb-test
, hspec
, mtl
, process
, timeit >=2.0
, transformers
, yapb
default-language: Haskell2010

0 comments on commit 59c1449

Please sign in to comment.