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