Visitar URL original
Add --quiet option for dhall decode by sjakobi · Pull Request #1803 · dhall-lang/dhall-haskell · GitHub
Skip to content

Add --quiet option for dhall decode - #1803

Merged
mergify[bot] merged 2 commits into
masterfrom
sjakobi/decode-quiet
May 22, 2020
Merged

mergify[bot] merged 2 commits into
masterfrom
sjakobi/decode-quiet

Conversation

@sjakobi

@sjakobi sjakobi commented May 21, 2020

Copy link
Copy Markdown
Collaborator

This is intended primarily for investigating decoding performance.

This is intended primarily for investigating decoding performance.
@sjakobi

sjakobi commented May 21, 2020

Copy link
Copy Markdown
Collaborator Author

Sample measurement from my machine:

$ echo 'https://raw.githubusercontent.com/vmchale/cpkg/0003ec5af2859008424aec06c2db0437a6a22ff9/pkgs/pkg-set.dhall' | dhall --alpha | dhall encode > tmp
$ bench "dhall decode --quiet --file tmp"
benchmarking dhall decode --quiet --file tmp
time                 415.9 ms   (409.3 ms .. 430.8 ms)
                     1.000 R²   (1.000 R² .. 1.000 R²)
mean                 417.1 ms   (414.8 ms .. 418.8 ms)
std dev              2.680 ms   (0.0 s .. 3.029 ms)
variance introduced by outliers: 19% (moderately inflated)
$ wc -c tmp
5147490 tmp
$ ghc -e '5147490 / (1024 * 1024) / 0.4159'
11.803387850343851

So 11.8 MB/s.

Comment thread dhall/src/Dhall/Main.hs
Comment on lines +825 to +831
if quiet
then return ()
else do
let doc =
Dhall.Pretty.prettyCharacterSet
characterSet
(Dhall.Core.renote expression :: Expr Src Import)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(style comment) use unless (from Control.Monad):

Suggested change
if quiet
then return ()
else do
let doc =
Dhall.Pretty.prettyCharacterSet
characterSet
(Dhall.Core.renote expression :: Expr Src Import)
unless quiet $ do
let doc =
Dhall.Pretty.prettyCharacterSet
characterSet
(Dhall.Core.renote expression :: Expr Src Import)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. When I started contributing to dhall, I often wanted to use unless and similar utils too, but realized that Gabriel mostly sticks to if. These days, I find this if-style actually more readable than the implicit negation of unless.

@sjakobi sjakobi mentioned this pull request May 21, 2020
4 tasks
@mergify
mergify Bot merged commit e9a94b9 into master May 22, 2020
@mergify
mergify Bot deleted the sjakobi/decode-quiet branch May 22, 2020 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants