diff --git a/README.md b/README.md index 9d33523..73441e8 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,24 @@ And each of them with `stack build `, for example: $ stack build dhall-json ``` +## Profiling + +Say you want to profile the `dhall-to-json` executable. + +Build the containing package with profiling options: + +```console +$ stack build --profile --library-profiling dhall-json +``` + +Run the executable on your input. For example: + +```console +$ stack exec --profile --rts-options -p -- dhall-to-json <<< 'True && False' +``` + +This generates a `dhall-to-json.prof` file in your current directory. + ## Build the website Building the website from source is currently only supported for Nix on Linux. diff --git a/appveyor.yml b/appveyor.yml index c459ee7..72bb3a9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -62,6 +62,8 @@ for: - stack test dhall-text - stack test dhall-bash # - stack test dhall-lsp-server # Disabled while the tests are broken. + - stack bench --benchmark-arguments "--quick --min-duration=0 --include-first-iter" + - matrix: only: diff --git a/dhall/benchmark/dhall-command/Main.hs b/dhall/benchmark/dhall-command/Main.hs deleted file mode 100644 index 311c8b1..0000000 --- a/dhall/benchmark/dhall-command/Main.hs +++ /dev/null @@ -1,20 +0,0 @@ - -{-# LANGUAGE OverloadedStrings #-} - -module Main where - -import qualified Dhall.Main as Main -import Dhall.Binary (defaultStandardVersion) - -options :: Main.Options -options = Main.Options - { Main.mode = Main.Default Nothing False False - , Main.explain = False - , Main.plain = False - , Main.ascii = False - , Main.standardVersion = defaultStandardVersion - } - -main :: IO () -main = do - Main.command options diff --git a/dhall/benchmark/parser/Main.hs b/dhall/benchmark/parser/Main.hs index 7f44e73..27280a1 100644 --- a/dhall/benchmark/parser/Main.hs +++ b/dhall/benchmark/parser/Main.hs @@ -38,7 +38,7 @@ listDirectory path = filter f <$> getDirectoryContents path type PreludeFiles = Map FilePath T.Text loadPreludeFiles :: IO PreludeFiles -loadPreludeFiles = loadDirectory "Prelude" +loadPreludeFiles = loadDirectory "./dhall-lang/Prelude" where loadDirectory :: FilePath -> IO PreludeFiles loadDirectory dir = diff --git a/dhall/dhall.cabal b/dhall/dhall.cabal index 3f80522..26cb97f 100644 --- a/dhall/dhall.cabal +++ b/dhall/dhall.cabal @@ -607,13 +607,3 @@ Benchmark deep-nested-large-record dhall , gauge >= 0.2.3 && < 0.3 Default-Language: Haskell2010 - -Benchmark dhall-command - Type: exitcode-stdio-1.0 - Main-Is: Main.hs - Hs-Source-Dirs: benchmark/dhall-command - Build-Depends: - base >= 4 && < 5 , - dhall - Default-Language: Haskell2010 - ghc-options: -rtsopts -O2 diff --git a/nix/shared.nix b/nix/shared.nix index d4d51d4..295eff1 100644 --- a/nix/shared.nix +++ b/nix/shared.nix @@ -1,6 +1,15 @@ { compiler ? "ghc843", coverage ? false, system ? builtins.currentSystem }: let + allDhallPackages = [ + "dhall" + "dhall-bash" + "dhall-json" + "dhall-lsp-server" + "dhall-nix" + "dhall-text" + ]; + fetchNixpkgs = import ./fetchNixpkgs.nix; mass = function: names: haskellPackagesNew: haskellPackagesOld: @@ -136,6 +145,9 @@ let ++ pkgsNew.lib.optional (!(compiler == "ghcjs" || compiler == "ghc7103")) "dhall" ); + doBenchmarkExtension = + mass pkgsNew.haskell.lib.doBenchmark allDhallPackages; + failOnAllWarningsExtension = mass failOnAllWarnings [ "dhall" @@ -212,6 +224,7 @@ let [ (pkgsNew.haskell.lib.packagesFromDirectory { directory = ./.; }) extension doCheckExtension + doBenchmarkExtension failOnAllWarningsExtension ]; } @@ -573,9 +586,7 @@ let ''; }; - toShell = drv: - # Benchmark dependencies aren't added by default - (pkgs.haskell.lib.doBenchmark drv).env; + toShell = drv: drv.env; possibly-static = { dhall = makeStaticIfPossible "dhall" ; @@ -619,13 +630,13 @@ in inherit (pkgs.releaseTools) aggregate; - shell-dhall = toShell pkgs.haskell.packages."${compiler}".dhall ; - shell-dhall-bash = toShell pkgs.haskell.packages."${compiler}".dhall-bash ; - shell-dhall-json = toShell pkgs.haskell.packages."${compiler}".dhall-json ; - shell-dhall-lsp-server = toShell pkgs.haskell.packages."${compiler}".dhall-lsp-server; - shell-dhall-nix = toShell pkgs.haskell.packages."${compiler}".dhall-nix ; - shell-dhall-text = toShell pkgs.haskell.packages."${compiler}".dhall-text ; - shell-dhall-try = toShell pkgs.haskell.packages."${compiler}".dhall-try ; + shell-dhall = pkgs.haskell.packages."${compiler}".dhall.env ; + shell-dhall-bash = pkgs.haskell.packages."${compiler}".dhall-bash.env ; + shell-dhall-json = pkgs.haskell.packages."${compiler}".dhall-json.env ; + shell-dhall-lsp-server = pkgs.haskell.packages."${compiler}".dhall-lsp-server.env; + shell-dhall-nix = pkgs.haskell.packages."${compiler}".dhall-nix.env ; + shell-dhall-text = pkgs.haskell.packages."${compiler}".dhall-text.env ; + shell-dhall-try = pkgs.haskell.packages."${compiler}".dhall-try.env ; image-dhall = toDockerImage "dhall" ; image-dhall-bash = toDockerImage "dhall-bash" ;