Add example modules for benchmarking and profiling

Summary:
This adds two new targets:
* `:duckling-expensive` - meant to have inputs for which running Duckling is expensive
* `:duckling-request-sample` - meant to have a random sample of inputs

The reason to have 2 of them is that they measure different things.
`:duckling-expensive` is correlated with failures,
`:duckling-request-sample` is correlated with cost.

I intend to add basic instruction on how to use them for
benchmarking/profiling soon.

Reviewed By: patapizza

Differential Revision: D5301554

fbshipit-source-id: f73fd85
This commit is contained in:
Bartosz Nitka 2017-06-22 09:01:04 -07:00 committed by Facebook Github Bot
parent 65f8ec170a
commit f48b536b1e
3 changed files with 60 additions and 0 deletions

View File

@ -748,6 +748,28 @@ executable duckling-example-exe
default-language: Haskell2010
default-extensions: OverloadedStrings
executable duckling-request-sample
main-is: DucklingRequestSample.hs
hs-source-dirs: exe
ghc-options: -threaded -rtsopts -with-rtsopts=-N
other-modules: Duckling.Data.TimeZone
build-depends: duckling
, base >= 4.8.2 && < 5.0
, dependent-sum >= 0.3.2.2 && < 0.5
default-language: Haskell2010
default-extensions: OverloadedStrings
executable duckling-expensive
main-is: DucklingExpensive.hs
hs-source-dirs: exe
ghc-options: -threaded -rtsopts -with-rtsopts=-N
other-modules: Duckling.Data.TimeZone
build-depends: duckling
, base >= 4.8.2 && < 5.0
, dependent-sum >= 0.3.2.2 && < 0.5
default-language: Haskell2010
default-extensions: OverloadedStrings
source-repository head
type: git
location: https://github.com/facebookincubator/duckling

16
exe/DucklingExpensive.hs Normal file
View File

@ -0,0 +1,16 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS -fno-full-laziness #-}
module Main (main) where
import Duckling.Debug
import Control.Monad
import System.Environment
import Duckling.Lang
import Data.Some
import Duckling.Dimensions.Types
main :: IO ()
main = do
(repeatCount :: Int) <- read . head <$> getArgs
void $ replicateM repeatCount $ void $ do
debug EN "Monday 3rd at 9.30am or 2.30pm, Saturday 8th at 10.30am, Tuesday 11th at 2pm, Wednesday 12th at 2.30pm, Friday 14th at 12.30pm xx" [This Time]
debug ES "Horario es de Lunes a Viernes de 2 pm a 10 pm. S\195\161bado de 9 am a 7 pm" [This Time]

View File

@ -0,0 +1,22 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS -fno-full-laziness #-}
module Main (main) where
import Duckling.Debug
import Control.Monad
import System.Environment
import Duckling.Lang
import Data.Some
import Duckling.Dimensions.Types
main :: IO ()
main = do
(repeatCount :: Int) <- read . head <$> getArgs
void $ replicateM repeatCount $ void $ do
debug EN "My number is 123" [This PhoneNumber,This Distance,This Numeral,This Email]
debug EN "Wednesday 5:00PM 3/29/2017" [This Numeral,This Time]
debug ZH "12:30pm" [This Time]
debug EN "tomorrow at 4pm" [This Time]
debug EN "Tomorrow at 12.30?" [This Time]
debug EN "Wednesday 9am" [This Time]
debug EN "Sure do! Will 11:30 work?" [This Time,This AmountOfMoney]
debug EN "8:00am" [This Time]