Command line options selected by the criteria library

I used the criteria of libraries and cmdargs.

When I completely compile a program without cmdargs and run it, for example .. / prog --help, then I get some unwanted answer from the criterion about the possible options and the number of runs, etc.

When I compile and run it, as below, the command line parameters are first selected by my code, and then read by the criterion. The criterion then reports and reports that the -byte option is unknown. I did not see anything in the documentation on the criterion of how this can be disabled or bypassed. Is there a way to clear the command line options that I read? Otherwise, I will need to use, for example, CPUTime instead of the criterion, this is normal for me, since I really require downloading additional functions and data that the criterion provides.

{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable #-} import System.Console.CmdArgs data Strlen = Strlen {byte :: Int} deriving (Data, Typeable, Show) strlen = cmdArgsMode $ Strlen {byte = def} &= summary "MessagePack benchmark v0.04" main = do n <- cmdArgsRun strlen let datastring = take (byte n) $ randomRs ('a','z') (mkStdGen 3) putStrLn "Starting..." conn <- connect "192.168.35.62" 8081 defaultMain [bench "sendReceive" $ whnfIO (mywl conn datastring)] 
+7
source share
2 answers

Use System.Environment.withArgs . cmdArgs command line arguments first with cmdArgs , then pass in what you did not use for criterion :

 main = do (flags, remaining) <- parseArgsHowever act according to flags withArgs remaining $ defaultMain [ ... ] 
+11
source

Look at the source of the criteria. You should be able to write your own defaultMainWith function that processes any arguments, including ignoring them or ignoring unknown arguments, etc.

+3
source

All Articles