Skip to content

Commit

Permalink
Also output benchmark results for vanillajs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfmpe committed Dec 18, 2017
1 parent 0dda09a commit d8e1593
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion benchmark.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ kill "$SERVER_PID"
exec 1>&3
echo "[";
paste -d ',' results/reflex-dom*;
paste -d ',' results/*;
echo "]";
''
23 changes: 17 additions & 6 deletions benchmarking/compareBenchmarkResults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Data.Aeson.TH
import Data.Align
import qualified Data.ByteString.Lazy as LBS
import Data.Either
import Data.Foldable
import qualified Data.Map as Map
import Data.Monoid
import qualified Data.Text as T
Expand Down Expand Up @@ -39,16 +40,26 @@ loadResult p = either error id . eitherDecode <$> LBS.readFile p
main :: IO ()
main = do
[file1, file2] <- getArgs
results1 <- loadResult file1
results2 <- loadResult file2
let byFramework = Map.fromListWith (<>) . map (_benchmarkResult_framework &&& pure)
befores = byFramework results1
afters = byFramework results2
inters = Map.intersectionWith (,) befores afters
traverse_ T.putStrLn $ Map.mapWithKey table inters

table :: Text -> ([BenchmarkResult], [BenchmarkResult]) -> Text
table framework (before, after) =
let resultMap = Map.fromList . fmap (_benchmarkResult_benchmark &&& _benchmarkResult_geometricMean)
getResults = fmap resultMap . loadResult
results1 <- getResults file1
results2 <- getResults file2
let showMNum = maybe "?" (T.pack . show)
results1 = resultMap before
results2 = resultMap after
showMNum = maybe "?" (T.pack . show)
title = "### " <> framework
header = "| Benchmark | Before | After | Ratio |"
separator = "| --- | --- | --- | --- |"
formatLine (b, rs) =
let r1 = preview here rs
r2 = preview there rs
in "| " <> b <> " | " <> showMNum r1 <> " | " <> showMNum r2 <> " | " <> showMNum ((/) <$> r2 <*> r1) <> " |"

T.putStrLn $ T.unlines $ header : separator : fmap formatLine (Map.toList $ align results1 results2)
in
T.unlines $ title : header : separator : fmap formatLine (Map.toList $ align results1 results2)

0 comments on commit d8e1593

Please sign in to comment.