Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add option to dump results as JUnit XML #16

Merged
merged 1 commit into from

2 participants

@tibbe

By dumping the results as JUnit XML we can plot them over time using e.g. the Jenkins Performance plugin.

@bos bos merged commit 3541a95 into bos:master
@rrnewton rrnewton referenced this pull request from a commit in rrnewton/criterion
@Shimuuar Shimuuar Change semantics if dct_ and idct_
They now transform only real part of vector. Imaginary part is
discarded. Previous behavior was to transform imaginary part
of vector with some linear transformation which is not DCT/IDCT

Should fix #16
27d6a2b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @tibbe
This page is out of date. Refresh to see the latest.
Showing with 33 additions and 1 deletion.
  1. +27 −1 Criterion.hs
  2. +4 −0 Criterion/Config.hs
  3. +2 −0  Criterion/Main.hs
View
28 Criterion.hs
@@ -138,7 +138,9 @@ runAndAnalyse p env bs' = do
Just compareFile -> do
liftIO $ writeFile compareFile $ resultForestToCSV rts
- plotAll $ flatten rts
+ let rs = flatten rts
+ plotAll rs
+ junit rs
where go :: String -> Benchmark -> Criterion ResultForest
go pfx (Benchmark desc b)
@@ -201,3 +203,27 @@ cmp ref r = (description ref, description r, percentFaster)
meanR = mean r
mean = estPoint . anMean . sampleAnalysis
+
+-- | Write summary JUnit file (if applicable)
+junit :: [Result] -> Criterion ()
+junit rs
+ = do junitOpt <- getConfigItem (getLast . cfgJUnitFile)
+ case junitOpt of
+ Just fn -> liftIO $ writeFile fn msg
+ Nothing -> return ()
+ where
+ msg = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++
+ printf "<testsuite name=\"Criterion benchmarks\" tests=\"%d\">\n"
+ (length rs) ++
+ concatMap single rs ++
+ "</testsuite>\n"
+ single r = printf " <testcase name=\"%s\" time=\"%f\" />\n"
+ (attrEsc $ description r) (estPoint $ anMean $ sampleAnalysis r)
+ attrEsc = concatMap esc
+ where
+ esc '\'' = "&apos;"
+ esc '"' = "&quot;"
+ esc '<' = "&lt;"
+ esc '>' = "&gt;"
+ esc '&' = "&amp;"
+ esc c = [c]
View
4 Criterion/Config.hs
@@ -56,6 +56,7 @@ data Config = Config {
, cfgCompareFile :: Last FilePath -- ^ Filename of the comparison CSV.
, cfgTemplate :: Last FilePath -- ^ Filename of report template.
, cfgVerbosity :: Last Verbosity -- ^ Whether to run verbosely.
+ , cfgJUnitFile :: Last FilePath -- ^ Filename of JUnit report.
} deriving (Eq, Read, Show, Typeable)
instance Monoid Config where
@@ -76,6 +77,7 @@ defaultConfig = Config {
, cfgCompareFile = mempty
, cfgTemplate = ljust "report.tpl"
, cfgVerbosity = ljust Normal
+ , cfgJUnitFile = mempty
}
-- | Constructor for 'Last' values.
@@ -103,6 +105,7 @@ emptyConfig = Config {
, cfgCompareFile = mempty
, cfgTemplate = mempty
, cfgVerbosity = mempty
+ , cfgJUnitFile = mempty
}
appendConfig :: Config -> Config -> Config
@@ -119,5 +122,6 @@ appendConfig a b =
, cfgCompareFile = app cfgCompareFile a b
, cfgTemplate = app cfgTemplate a b
, cfgVerbosity = app cfgVerbosity a b
+ , cfgJUnitFile = app cfgJUnitFile a b
}
where app f = mappend `on` f
View
2  Criterion/Main.hs
@@ -118,6 +118,8 @@ defaultOptions = [
"display version, then exit"
, Option ['v'] ["verbose"] (noArg mempty { cfgVerbosity = ljust Verbose })
"print more output"
+ , Option [] ["junit"] (ReqArg (\s -> return $ mempty { cfgJUnitFile = ljust s }) "FILENAME")
+ "produce a JUnit report file of all results"
]
printBanner :: Config -> IO ()
Something went wrong with that request. Please try again.