Skip to content

Commit 299293c

Browse files
committed
Add cabal.bench.project for running benchmarks
1 parent eef26cf commit 299293c

File tree

6 files changed

+57
-25
lines changed

6 files changed

+57
-25
lines changed

.travis.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# For more information, see https://github.com/haskell-CI/haskell-ci
66
#
7-
# version: 0.9.20200402
7+
# version: 0.9.20200406
88
#
99
version: ~> 1.0
1010
language: c
@@ -35,25 +35,25 @@ jobs:
3535
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.10.1","cabal-install-3.2"]}}
3636
os: linux
3737
- compiler: ghc-8.8.3
38-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.3","cabal-install-3.0"]}}
38+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.8.3","cabal-install-3.2"]}}
3939
os: linux
4040
- compiler: ghc-8.6.5
41-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.0"]}}
41+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.6.5","cabal-install-3.2"]}}
4242
os: linux
4343
- compiler: ghc-8.4.4
44-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.4","cabal-install-3.0"]}}
44+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.4.4","cabal-install-3.2"]}}
4545
os: linux
4646
- compiler: ghc-8.2.2
47-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.0"]}}
47+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.2.2","cabal-install-3.2"]}}
4848
os: linux
4949
- compiler: ghc-8.0.2
50-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.0"]}}
50+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-8.0.2","cabal-install-3.2"]}}
5151
os: linux
5252
- compiler: ghc-7.10.3
53-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.10.3","cabal-install-3.0"]}}
53+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.10.3","cabal-install-3.2"]}}
5454
os: linux
5555
- compiler: ghc-7.8.4
56-
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.8.4","cabal-install-3.0"]}}
56+
addons: {"apt":{"sources":[{"sourceline":"deb http://ppa.launchpad.net/hvr/ghc/ubuntu xenial main","key_url":"https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x063dab2bdc0b3f9fcebc378bff3aeacef6f88286"}],"packages":["ghc-7.8.4","cabal-install-3.2"]}}
5757
os: linux
5858
before_install:
5959
- HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
@@ -108,10 +108,10 @@ install:
108108
- |
109109
echo "packages: ." >> cabal.project
110110
echo "packages: attoparsec-iso8601" >> cabal.project
111-
- if [ $HCNUMVER -ge 80000 ] ; then echo 'package aeson' >> cabal.project ; fi
112-
- "if [ $HCNUMVER -ge 80000 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
113-
- if [ $HCNUMVER -ge 80000 ] ; then echo 'package attoparsec-iso8601' >> cabal.project ; fi
114-
- "if [ $HCNUMVER -ge 80000 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
111+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package aeson' >> cabal.project ; fi
112+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
113+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package attoparsec-iso8601' >> cabal.project ; fi
114+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
115115
- |
116116
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(aeson|attoparsec-iso8601)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
117117
- cat cabal.project || true
@@ -140,10 +140,10 @@ script:
140140
- |
141141
echo "packages: ${PKGDIR_aeson}" >> cabal.project
142142
echo "packages: ${PKGDIR_attoparsec_iso8601}" >> cabal.project
143-
- if [ $HCNUMVER -ge 80000 ] ; then echo 'package aeson' >> cabal.project ; fi
144-
- "if [ $HCNUMVER -ge 80000 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
145-
- if [ $HCNUMVER -ge 80000 ] ; then echo 'package attoparsec-iso8601' >> cabal.project ; fi
146-
- "if [ $HCNUMVER -ge 80000 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
143+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package aeson' >> cabal.project ; fi
144+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
145+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package attoparsec-iso8601' >> cabal.project ; fi
146+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
147147
- |
148148
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(aeson|attoparsec-iso8601)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
149149
- cat cabal.project || true
@@ -169,6 +169,9 @@ script:
169169
# Constraint set cffi
170170
- ${CABAL} v2-build $WITHCOMPILER --enable-tests --disable-benchmarks --constraint='aeson +cffi' all
171171
- ${CABAL} v2-test $WITHCOMPILER --enable-tests --disable-benchmarks --constraint='aeson +cffi' all
172+
# Raw travis commands
173+
- cd $TOP || false
174+
- ${CABAL} v2-build $WITHCOMPILER --project-file=cabal.bench.project all
172175

173-
# REGENDATA ("0.9.20200402",["--config=cabal.haskell-ci","cabal.project"])
176+
# REGENDATA ("0.9.20200406",["--config=cabal.haskell-ci","cabal.project"])
174177
# EOF

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,23 @@ Of course before submitting a PR, the following steps are recommended:
9696
1. `cabal new-test` - Run the entire suite of tests
9797
2. `make hlint` - Run hlint on the source folders.
9898
3. Uncomment the `benchmarks` line in `cabal.project` - Run the benchmark tests if you believe your changes could affect the benchmarks.
99+
100+
### Running benchmarks
101+
102+
You need to install `cabal-plan` and `criterion-compare` with
103+
104+
```
105+
cabal install cabal-plan criterion-compare
106+
```
107+
108+
Then to build benchmarks we use a different project, which builds
109+
`aeson` as a package with a different name to avoid rebuilding `criterion`
110+
etc tools all the time:
111+
112+
```
113+
cabal build --project-file cabal.bench.project all
114+
```
115+
116+
Then to run benchmarks
117+
118+
... to be completed

benchmarks/aeson-benchmarks.cabal

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ library
3030
build-depends:
3131
attoparsec,
3232
base,
33-
base-compat,
33+
base-compat-batteries,
3434
containers,
3535
deepseq,
3636
dlist,
37-
fail,
3837
ghc-prim,
3938
hashable,
4039
mtl,
@@ -58,7 +57,8 @@ library
5857
if !impl(ghc >= 8.0)
5958
-- `Data.Semigroup` is available in base only since GHC 8.0 / base 4.9
6059
build-depends: semigroups,
61-
transformers-compat
60+
transformers-compat,
61+
fail
6262

6363
if !impl(ghc >= 7.10)
6464
-- `Numeric.Natural` is available in base only since GHC 7.10 / base 4.8
@@ -162,7 +162,7 @@ executable aeson-benchmark-compare
162162
build-depends:
163163
aeson-benchmarks,
164164
base,
165-
base-compat,
165+
base-compat-batteries,
166166
buffer-builder,
167167
bytestring,
168168
criterion >= 1.0,
@@ -175,9 +175,9 @@ executable aeson-benchmark-compare
175175
Compare.JsonBuilder
176176
build-depends:
177177
json-builder
178-
if impl(ghc < 8.0)
179-
build-depends:
180-
semigroups
178+
179+
if !impl(ghc >= 8.0)
180+
build-depends: semigroups, fail
181181

182182
executable aeson-benchmark-micro
183183
default-language: Haskell2010
@@ -267,6 +267,9 @@ executable aeson-benchmark-aeson-parse
267267
bytestring,
268268
time
269269

270+
if !impl(ghc >= 8.0)
271+
build-depends: semigroups, fail
272+
270273
executable aeson-benchmark-json-parse
271274
default-language: Haskell2010
272275
main-is: JsonParse.hs

cabal.bench.project

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
with-compiler: ghc
2+
packages: benchmarks/
3+
tests: false

cabal.haskell-ci

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ constraint-set cffi
1212
constraints: aeson +cffi
1313
tests: True
1414
run-tests: True
15+
16+
raw-travis:
17+
cd $TOP || false
18+
${CABAL} v2-build $WITHCOMPILER --project-file=cabal.bench.project all

cabal.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
with-compiler: ghc
22
packages: .
33
packages: attoparsec-iso8601
4-
-- packages: benchmarks
54
tests: true

0 commit comments

Comments
 (0)