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

Add --quiet option for dhall decode #1803

Merged
merged 2 commits into from
May 22, 2020
Merged

Add --quiet option for dhall decode #1803

merged 2 commits into from
May 22, 2020

Conversation

sjakobi
Copy link
Collaborator

@sjakobi sjakobi commented May 21, 2020

This is intended primarily for investigating decoding performance.

This is intended primarily for investigating decoding performance.
@sjakobi
Copy link
Collaborator Author

sjakobi commented May 21, 2020

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 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
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
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.

None yet

2 participants