Skip to content

Commit 25bfa3b

Browse files
authored
Merge pull request #7 from haskell-perf/newStack
New stack
2 parents cd88f8c + fb5d615 commit 25bfa3b

File tree

16 files changed

+19452
-2061
lines changed

16 files changed

+19452
-2061
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ env:
3535
- DO=TIME STEP=0
3636
- DO=TIME STEP=1
3737
- DO=TIME STEP=2
38+
- DO=TIME STEP=3
3839
- DO=SPACE
39-
- DO=DATASIZE
4040

4141
install:
4242
# Build dependencies
@@ -45,9 +45,8 @@ install:
4545
script:
4646
# Build the package, its tests, and its docs and run the tests
4747
- stack --no-terminal bench --no-run-benchmarks
48-
- PREFIX=.stack-work/dist/x86_64-linux/Cabal-2.0.1.0/build
49-
- if [ $DO = DATASIZE ]; then travis_wait $PREFIX/datasize/datasize; else if [ $DO = SPACE ]; then travis_wait 30 $PREFIX/space/space; else $PREFIX/time/time run --part $STEP --of 3 -g '("Mesh",2)' -g '("Clique",2)' ; fi; fi;
50-
48+
- PREFIX=.stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build
49+
- if [ $DO = SPACE ]; then travis_wait 30 $PREFIX/space/space; else $PREFIX/time/time run --part $STEP --of 4 -g '("Mesh",2)' -g '("Clique",2)' ; fi;
5150

5251
before_install:
5352
# Download and unpack the stack executable

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Benchmark suite for graph libraries
22

3-
## Warning: Under Active Developement
4-
This is being developed as part of the Google Summer of Code 2018.
5-
Please do not expect anything from the code for now.
6-
7-
Feel free to open an issue anyway :)
3+
## Intro
4+
This project was developed as part of the Google Summer of Code 2018.
5+
Feel free to open an issue :)
86

97
## Results
10-
Current results of `cabal bench time` and `cabal bench space` can be found here: https://travis-ci.org/haskell-perf/graphs
8+
9+
![svg](https://raw.githubusercontent.com/haskell-perf/graphs/newStack/results/TIME.svg?sanitize=true)
10+
11+
Current results of `cabal bench time` and `cabal bench space` can be found here: <https://travis-ci.org/haskell-perf/graphs>
1112

1213
Results on bigger graphs and with more beautiful output can be found here: <https://github.com/haskell-perf/graphs/tree/master/results>
1314

@@ -21,7 +22,7 @@ You can customize your build using several cabal flags (all of them are on by de
2122

2223
* Time: will produce a benchmark suite using `criterion`.
2324
* Space: will produce a benchmark suite using `weigh`.
24-
* Datasize: will produce a benchmark suite using `ghc-datasize`.
25+
* Datasize: will produce a benchmark suite using `ghc-datasize` (disabled by default).
2526

2627
### Libraries
2728

@@ -63,9 +64,13 @@ The benchmark suite `datasize` will use `ghc-datasize` to calculate size of grap
6364
### Arguments
6465

6566
Command-line arguments are self-explaining, but the `--graph "(String,Int)"` requires some explanations:
66-
We test functions against standards graphs, and they are built with ten-powers vertices. For standard graphs, the Int supplied is the upper-bound of the ten-powers. So `"(Path,100)"` will generate the `Path` with `1`, `10` and `100` vertices. You can specify several graphs.
67+
Standards graphs are built with ten-powers vertices. The `Int` supplied is the upper-bound of these ten-powers. So `"(Path,3)"` will generate three `Path` with `1`, `10` and `100` vertices. You can specify several graphs.
68+
69+
You can force the suite to use only bigger graphs with the `-i` flag.
70+
71+
The default is: `[("Mesh",3),("Clique",3)]`.
6772

68-
The default is: `[("Mesh",3),("Clique",3)]`
73+
For real-life graphs (see below) you cannot use an integer greater than 4.
6974

7075
#### Real-life graphs
7176

@@ -86,6 +91,14 @@ The following graphs are supported:
8691
* Clique
8792
* RealLife (Note that because we have a limited set, you cannot request more than 4 real-life graphs)
8893

94+
### Charts
95+
96+
One can produce a chart from the results, use:
97+
98+
```
99+
-f,--chartfile FILENAME Output file WITHOUT extension
100+
-c,--chart OUTTYPE Output type: Png or Svg
101+
```
89102

90103
## About implementation
91104

@@ -131,7 +144,6 @@ data Suite g = forall i o. NFData o => Suite
131144

132145
This module defines common builders for `Suite`, and particularly provides stable names for standard operations on graphs, and thus allows for simpler comparison (remember, benchmarks are identified by their _name_).
133146

134-
135147
### Benchmarking with creation?
136148

137149
We provide two ways of benchmarking:

bench/Space.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
22
{-# LANGUAGE CPP #-}
33

4-
import Data.List (nub, nubBy, sortBy, elemIndices)
4+
import Data.List (nub, nubBy, sort, sortBy, elemIndices)
55
import Data.Function (on)
66
import Data.Maybe (mapMaybe, catMaybes, isJust)
77
import Data.Int (Int64)
@@ -67,7 +67,7 @@ takeLastAfterBk w = case elemIndices '/' w of
6767
useResults :: Output -> [Named (Named String)] -> [Grouped (Weight, Maybe String)] -> IO ()
6868
useResults flg notDef todo = do
6969
putStrLn "Note: results are in bytes"
70-
results <- mapM mapped $ nubBy (liftExtract2 eqG) namedBenchs
70+
results <- fmap catMaybes $ mapM mapped $ nubBy (liftExtract2 eqG) namedBenchs
7171
maybe (return ()) (\x -> writeFile x $ show results) $ saveToFile flg
7272
case figOut flg of
7373
Nothing -> return ()
@@ -91,9 +91,9 @@ useResults flg notDef todo = do
9191
printAbstract "lighter" onlyLargeBenchs
9292
return $ Just (showGrouped $ snd e, onlyLargeBenchs)
9393

94-
renderG :: T.ChartOutput -> [Maybe (Named (T.Grouped [Named Double]))] -> IO ()
94+
renderG :: T.ChartOutput -> [Named (T.Grouped [Named Double])] -> IO ()
9595
#ifdef CHART
96-
renderG x results = mkChart "Space results" defaultGr show x $ Left $ catMaybes results
96+
renderG x results = mkChart "Space results" defaultGr show x $ Left $ sortBy (on compare fst) results
9797
#else
9898
renderG _ _ = return ()
9999
#endif
@@ -189,7 +189,7 @@ main' (Run only notonly flg libs _ _ _) = do
189189
benchsNames :: Maybe Option -> Maybe [String] -> [String]
190190
benchsNames only notonly = nub $ useNotOnly $ useOnly extractedNames
191191
where
192-
extractedNames = "creation" : map (\(_,Shadow s) -> either fst name s) listOfSuites
192+
extractedNames = sort $ "creation" : map (\(_,Shadow s) -> either fst name s) listOfSuites
193193
useOnly = case only of
194194
Nothing -> id
195195
(Just (Only lst)) -> filter (`elem` lst)

bench/Time.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ genReport gr flg arr = do
7979
unless notquickComp $ putStrLn $ let comp = head libNames
8080
oth = head $ tail libNames
8181
in unwords ["\nComparing",comp,"to",oth,". It means that the displayed number will be k such that", comp,"= k *", oth ]
82-
results <- mapM mapped $ nubBy (liftExtract2 (==)) refinedarr
82+
results <- fmap catMaybes $ mapM mapped $ nubBy (liftExtract2 (==)) refinedarr
8383
maybe (return ()) (\x -> writeFile x $ unlines [show gr,show results]) $ saveToFile flg
8484
case figOut flg of
8585
Nothing -> return ()
86-
(Just x) -> renderG gr x results
86+
(Just x) -> renderG gr x results
8787
where
8888
mapped e = do
8989
let bname = showBenchName $ snd e
@@ -110,9 +110,9 @@ genReport gr flg arr = do
110110
notquickComp = staOut flg /= QuickComparison
111111
(noimpl,refinedarr) = partitionEithers $ map stripOutEither arr
112112

113-
renderG :: [(String,Int)] -> ChartOutput -> [Maybe (Name, Grouped [(Name, (Double, Double))])] -> IO ()
113+
renderG :: [(String,Int)] -> ChartOutput -> [(Name, Grouped [(Name, (Double, Double))])] -> IO ()
114114
#ifdef CHART
115-
renderG gr x results = mkChart "Time results" gr secs x $ Right $ catMaybes results
115+
renderG gr x results = mkChart "Time results" gr secs x $ Right $ sortBy (on compare fst) results
116116
#else
117117
renderG _ _ _ = return ()
118118
#endif
@@ -210,7 +210,7 @@ main' opts
210210
Libs -> putStr $ unlines $ nub $ map fst listOfSuites ++ map fst (listOfCreation False [])
211211
Render filep dg -> do
212212
(gr,res) <- span (/='\n') <$> readFile filep
213-
renderG (read gr) dg (read res)
213+
renderG (read gr) dg $ read res
214214
Run opt nottodo' flg libs benchWithCreation dontBenchLittleOnes gr' -> do
215215
let modifyL = case libs of
216216
Nothing -> id
@@ -231,7 +231,7 @@ main' opts
231231
genReport gr flg samples
232232
where
233233
grNames = nub $ map (either fst showBenchName . snd) $ grList False False defaultGr
234-
grList benchWithCreation dontBenchLittleOnes gr =
234+
grList benchWithCreation dontBenchLittleOnes gr = sortBy (on compare (either fst showBenchName . snd)) $
235235
map (fmap (\(Shadow s) -> second (allBench benchWithCreation dontBenchLittleOnes gr) s)) listOfSuites
236236
++ listOfCreation dontBenchLittleOnes gr
237237
mkGr gr' = case gr' of

results/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
## Results
22

33
* Time: https://github.com/haskell-perf/graphs/blob/master/results/TIME.md
4+
5+
![svg](https://raw.githubusercontent.com/haskell-perf/graphs/newStack/results/TIME.svg?sanitize=true)
6+
47
* Space: https://github.com/haskell-perf/graphs/blob/master/results/SPACE.md
58

6-
Note: Some functions of Data.Graph was not in the original library (`edgeCount` and `hasEdge`), their defintion can be found in `bench/Containers/Graph.hs`
9+
Note: Some functions of some libraries are not implemented so we use a "hand-made" implementation. Defintions can be found in `bench/`. Suggestions are welcome!
710

811
## What is benchmarked
912

@@ -14,7 +17,7 @@ In this folder, you will find the lastest benchmarks of 4 haskell graphs librari
1417
* [FGL v5.6.0.0](https://hackage.haskell.org/package/fgl-5.6.0.0)
1518
* [Hash-Graph (not yet on hackage)](https://github.com/patrickdoc/hash-graph)
1619

17-
The benchmarks were realised using `Stack` and the `stack.newest.yaml` configuration
20+
The benchmarks were realised using `Stack` and the `stack.yaml` configuration
1821

1922
## Tools
2023

@@ -27,11 +30,22 @@ The benchmarks were realised using `Stack` and the `stack.newest.yaml` configura
2730
### Benchmarking routine
2831

2932
For the main results, we produce a generic list of edges (in ascending orders, but none of the libraries rely on this), create a graph from it, fully evaluate this graph to Normal Form, then pass it to then benchmarked function.
30-
This may not reflect the reality, so we produced https://github.com/haskell-perf/graphs/blob/master/results/TIME-creation.md where the creation time (from a list of edges) is taken into account.
33+
34+
#### Creation
35+
36+
This may not reflect the reality, so we produced an alternative table where creation time (from a list of edges) is taken into account:
37+
38+
![svg](https://raw.githubusercontent.com/haskell-perf/graphs/newStack/results/TIME-creation.svg?sanitize=true)
39+
40+
<https://github.com/haskell-perf/graphs/blob/master/results/TIME-creation.md>
3141

3242
### The list of edges
3343

34-
Containers, Fgl and Hash-Graph are dealing well with a list of edges. This is *not* the case with Alga, so we produced https://github.com/haskell-perf/graphs/blob/master/results/TIME-extra.md where we used the alga representation instead of a list of edges.
44+
Containers, Fgl and Hash-Graph are dealing well with a list of edges. This is *not* the case with Alga, so we produced an alternative table where we used the alga representation instead of a list of edges:
45+
46+
![svg](https://raw.githubusercontent.com/haskell-perf/graphs/newStack/results/TIME-extra.svg?sanitize=true)
47+
48+
<https://github.com/haskell-perf/graphs/blob/master/results/TIME-extra.md>
3549

3650
## Some words about graphs
3751
The functions are benchmarked against:
@@ -56,9 +70,11 @@ The functions are benchmarked against:
5670
The two first graphs are built with successive ten powers vertices. Here, with 1, 10, 100 and 1000 vertices.
5771

5872
### Types
73+
5974
Libraries are benchmarked against graphs with *Int* vertices.
6075

6176
## About arguments
77+
6278
All the functions are tested with arguments in the _domain_ of the graph, where applicable: unless it is mentioned, edges and vertices generated for the test can be in the complete graph with the same number of vertices.
6379

6480
## Remarks

0 commit comments

Comments
 (0)