build cleanrly when benchmark flag is not enabled
This commit is contained in:
parent
fc3fd0cfe0
commit
5ba14b5095
3 changed files with 16 additions and 6 deletions
|
@ -120,9 +120,7 @@ import qualified Command.WebApp
|
|||
import qualified Command.Test
|
||||
import qualified Command.FuzzTest
|
||||
import qualified Command.TestRemote
|
||||
#ifdef WITH_BENCHMARK
|
||||
import qualified Command.Benchmark
|
||||
#endif
|
||||
|
||||
cmds :: Parser TestOptions -> TestRunner -> MkBenchmarkGenerator -> [Command]
|
||||
cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||
|
@ -229,10 +227,8 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
|||
, Command.Test.cmd testoptparser testrunner
|
||||
, Command.FuzzTest.cmd
|
||||
, Command.TestRemote.cmd
|
||||
#ifdef WITH_BENCHMARK
|
||||
, Command.Benchmark.cmd $
|
||||
mkbenchmarkgenerator $ cmds testoptparser testrunner (\_ _ -> return noop)
|
||||
#endif
|
||||
]
|
||||
|
||||
run :: Parser TestOptions -> TestRunner -> MkBenchmarkGenerator -> [String] -> IO ()
|
||||
|
|
|
@ -5,15 +5,17 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Command.Benchmark where
|
||||
|
||||
import Command
|
||||
import Types.Benchmark
|
||||
|
||||
#ifdef WITH_BENCHMARK
|
||||
import Criterion.Main
|
||||
import Criterion.Main.Options (parseWith, Mode)
|
||||
#endif
|
||||
|
||||
cmd :: BenchmarkGenerator -> Command
|
||||
cmd generator = command "benchmark" SectionTesting
|
||||
|
@ -21,15 +23,27 @@ cmd generator = command "benchmark" SectionTesting
|
|||
paramNothing
|
||||
(seek generator <$$> optParser)
|
||||
|
||||
#ifndef WITH_BENCHMARK
|
||||
type Mode = ()
|
||||
#endif
|
||||
|
||||
data BenchmarkOptions = BenchmarkOptions CmdParams Mode
|
||||
|
||||
optParser :: CmdParamsDesc -> Parser BenchmarkOptions
|
||||
optParser desc = BenchmarkOptions
|
||||
<$> cmdParams desc
|
||||
#ifdef WITH_BENCHMARK
|
||||
-- parse criterion's options
|
||||
<*> parseWith defaultConfig
|
||||
#else
|
||||
<*> pure ()
|
||||
#endif
|
||||
|
||||
seek :: BenchmarkGenerator -> BenchmarkOptions -> CommandSeek
|
||||
#ifdef WITH_BENCHMARK
|
||||
seek generator (BenchmarkOptions ps mode) = do
|
||||
runner <- generator ps
|
||||
liftIO $ runMode mode [ bench (unwords ps) $ nfIO runner ]
|
||||
#else
|
||||
seek _ _ = giveup "git-annex is not built with benchmarking support"
|
||||
#endif
|
||||
|
|
|
@ -588,7 +588,6 @@ Executable git-annex
|
|||
if flag(Benchmark)
|
||||
Build-Depends: criterion, deepseq
|
||||
CPP-Options: -DWITH_BENCHMARK
|
||||
Other-Modules: Command.Benchmark
|
||||
|
||||
if flag(DebugLocks)
|
||||
CPP-Options: -DDEBUGLOCKS
|
||||
|
@ -690,6 +689,7 @@ Executable git-annex
|
|||
Command.AddUnused
|
||||
Command.AddUrl
|
||||
Command.Adjust
|
||||
Command.Benchmark
|
||||
Command.CalcKey
|
||||
Command.CheckPresentKey
|
||||
Command.Commit
|
||||
|
|
Loading…
Reference in a new issue