aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2018-12-16 01:02:08 +0100
committerDaniel Gröber <dxld@darkboxed.org>2019-01-22 03:06:51 +0100
commit571448ca604065a6e6bfe7e6423b8ae6789b4dd9 (patch)
treedf59ef3ea82b55e1069e0d7c13dd748a7bdc8be3
parent842de542f71616b6d828ea2f993f227e59f1ebc5 (diff)
Add helper compilation time to debug output
-rw-r--r--cabal-helper.cabal1
-rw-r--r--lib/Distribution/Helper.hs7
-rw-r--r--src/CabalHelper/Compiletime/Compile.hs6
3 files changed, 14 insertions, 0 deletions
diff --git a/cabal-helper.cabal b/cabal-helper.cabal
index 53bb093..5bcf6ba 100644
--- a/cabal-helper.cabal
+++ b/cabal-helper.cabal
@@ -80,6 +80,7 @@ common build-deps
build-depends: base < 5 && >= 4.8
, Cabal < 2.5 && >= 2.0 || < 1.26 && >= 1.14
, cabal-plan < 0.5 && >= 0.3.0.0
+ , clock < 0.8 && >= 0.7.2
, containers < 1 && >= 0.5.5.1
, bytestring < 0.11 && >= 0.9.2.1
, directory < 1.4 && >= 1.2.1.0
diff --git a/lib/Distribution/Helper.hs b/lib/Distribution/Helper.hs
index bafe3ca..7c3261f 100644
--- a/lib/Distribution/Helper.hs
+++ b/lib/Distribution/Helper.hs
@@ -110,6 +110,7 @@ import qualified Data.List.NonEmpty as NonEmpty
import Data.Version
import Data.Function
import Data.Functor.Apply
+import System.Clock as Clock
import System.Environment
import System.FilePath hiding ((<.>))
import System.Directory
@@ -124,6 +125,7 @@ import qualified CabalHelper.Compiletime.Program.Stack as Stack
import qualified CabalHelper.Compiletime.Program.GHC as GHC
import qualified CabalHelper.Compiletime.Program.CabalInstall as CabalInstall
import CabalHelper.Compiletime.Cabal
+import CabalHelper.Compiletime.Log
import CabalHelper.Compiletime.Sandbox
import CabalHelper.Compiletime.Types
import CabalHelper.Compiletime.Types.RelativePath
@@ -576,7 +578,12 @@ getHelperExe proj_info QueryEnv{..} = do
let comp = wrapper' qeProjLoc qeDistDir proj_info
let ?progs = qePrograms
?cprogs = qeCompPrograms
+ t0 <- Clock.getTime Monotonic
eexe <- compileHelper comp
+ t1 <- Clock.getTime Monotonic
+ let dt = (/10e9) $ fromInteger $ Clock.toNanoSecs $ Clock.diffTimeSpec t0 t1
+ dt :: Float
+ vLog $ printf "compileHelper took %.5fs" dt
case eexe of
Left rv ->
panicIO $ "compileHelper': compiling helper failed! exit code "++ show rv
diff --git a/src/CabalHelper/Compiletime/Compile.hs b/src/CabalHelper/Compiletime/Compile.hs
index 78c052e..97adac2 100644
--- a/src/CabalHelper/Compiletime/Compile.hs
+++ b/src/CabalHelper/Compiletime/Compile.hs
@@ -39,6 +39,7 @@ import Data.Maybe
import Data.String
import Data.Version
import Text.Printf
+import qualified System.Clock as Clock
import System.Directory
import System.FilePath
import System.Exit
@@ -114,6 +115,7 @@ compileHelper'
=> CompHelperEnv' UnpackedCabalVersion
-> IO (Either ExitCode FilePath)
compileHelper' CompHelperEnv {..} = do
+ t0 <- Clock.getTime Clock.Monotonic
ghcVer <- ghcVersion
Just (prepare, comp) <- case cheCabalVer of
cabalVer@CabalHEAD {} -> do
@@ -143,6 +145,10 @@ compileHelper' CompHelperEnv {..} = do
vLog $ "helper exe does not exist, compiling "++compExePath
prepare >> compile cp comp
+ t1 <- Clock.getTime Clock.Monotonic
+ let dt = (/10e9) $ fromInteger $ Clock.toNanoSecs $ Clock.diffTimeSpec t0 t1
+ dt :: Float
+ vLog $ printf "compileHelper took %.5fs" dt
return rv