Skip to content

Commit 4d12557

Browse files
authored
Merge pull request #772 from phadej/benchmarks-running
Add cabal.bench.project for running benchmarks
2 parents eef26cf + c321210 commit 4d12557

28 files changed

+2927
-312
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
dist
22
dist-newstyle
33
.ghc.environment.*
4+
cabal.project.local
45
.cabal-sandbox/
56
cabal.sandbox.config
67
.stack-work/
78
.stack-work-bench/
89
*.yaml.lock
10+
.bench-results
911

1012
*.o
1113
*.hi

.travis.yml

Lines changed: 31 additions & 19 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,16 +108,20 @@ 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+
echo "packages: examples" >> cabal.project
112+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package aeson' >> cabal.project ; fi
113+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
114+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package attoparsec-iso8601' >> cabal.project ; fi
115+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
116+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package aeson-examples' >> cabal.project ; fi
117+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
115118
- |
116-
- "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"
119+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(aeson|aeson-examples|attoparsec-iso8601)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
117120
- cat cabal.project || true
118121
- cat cabal.project.local || true
119122
- if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi
120123
- if [ -f "attoparsec-iso8601/configure.ac" ]; then (cd "attoparsec-iso8601" && autoreconf -i); fi
124+
- if [ -f "examples/configure.ac" ]; then (cd "examples" && autoreconf -i); fi
121125
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
122126
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
123127
- rm cabal.project.freeze
@@ -134,18 +138,22 @@ script:
134138
- find . -maxdepth 1 -type f -name '*.tar.gz' -exec rm '{}' \;
135139
- PKGDIR_aeson="$(find . -maxdepth 1 -type d -regex '.*/aeson-[0-9.]*')"
136140
- PKGDIR_attoparsec_iso8601="$(find . -maxdepth 1 -type d -regex '.*/attoparsec-iso8601-[0-9.]*')"
141+
- PKGDIR_aeson_examples="$(find . -maxdepth 1 -type d -regex '.*/aeson-examples-[0-9.]*')"
137142
# Generate cabal.project
138143
- rm -rf cabal.project cabal.project.local cabal.project.freeze
139144
- touch cabal.project
140145
- |
141146
echo "packages: ${PKGDIR_aeson}" >> cabal.project
142147
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"
148+
echo "packages: ${PKGDIR_aeson_examples}" >> cabal.project
149+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package aeson' >> cabal.project ; fi
150+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
151+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package attoparsec-iso8601' >> cabal.project ; fi
152+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
153+
- if [ $HCNUMVER -ge 80200 ] ; then echo 'package aeson-examples' >> cabal.project ; fi
154+
- "if [ $HCNUMVER -ge 80200 ] ; then echo ' ghc-options: -Werror=missing-methods' >> cabal.project ; fi"
147155
- |
148-
- "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"
156+
- "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | (grep -vE -- '^(aeson|aeson-examples|attoparsec-iso8601)$' || true) | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
149157
- cat cabal.project || true
150158
- cat cabal.project.local || true
151159
# Building...
@@ -159,6 +167,7 @@ script:
159167
# HLint..
160168
- if [ $HCNUMVER -ge 80800 ] && [ $HCNUMVER -lt 81000 ] ; then (cd ${PKGDIR_aeson} && hlint -h ${TOP}/.hlint.yaml . attoparsec-iso8601/ pure ffi) ; fi
161169
- if [ $HCNUMVER -ge 80800 ] && [ $HCNUMVER -lt 81000 ] ; then (cd ${PKGDIR_attoparsec_iso8601} && hlint -h ${TOP}/.hlint.yaml .) ; fi
170+
- if [ $HCNUMVER -ge 80800 ] && [ $HCNUMVER -lt 81000 ] ; then (cd ${PKGDIR_aeson_examples} && hlint -h ${TOP}/.hlint.yaml src/) ; fi
162171
# haddock...
163172
- if [ $HCNUMVER -ge 80600 ] ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all ; fi
164173
# Building without installed constraints for packages in global-db...
@@ -169,6 +178,9 @@ script:
169178
# Constraint set cffi
170179
- ${CABAL} v2-build $WITHCOMPILER --enable-tests --disable-benchmarks --constraint='aeson +cffi' all
171180
- ${CABAL} v2-test $WITHCOMPILER --enable-tests --disable-benchmarks --constraint='aeson +cffi' all
181+
# Raw travis commands
182+
- cd $TOP || false
183+
- ${CABAL} v2-build $WITHCOMPILER --project-file=cabal.bench.project all
172184

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

CONTRIBUTING.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,38 @@ 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`:
103+
104+
```
105+
cabal install cabal-plan
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. There is a helper script which usage
111+
can be as simple as:
112+
113+
```
114+
git checkout master
115+
./bench.sh run -n master
116+
git checkout your-branch
117+
./bench.sh run -n your-branch
118+
./bench.sh compare master your-branch
119+
```
120+
121+
which will output a table like
122+
123+
```
124+
Benchmark master your-branch
125+
Examples/decode/github-issues/lazy 1.77e-3 1.76e-3 -0.68%
126+
Examples/decode/github-issues/strict 1.75e-3 1.69e-3 -3.29%
127+
Examples/decode/jp100/lazy 1.97e-3 1.98e-3 +0.43%
128+
Examples/decode/jp100/strict 1.94e-3 1.96e-3 +1.10%
129+
Examples/decode/twitter100/lazy 1.54e-3 1.59e-3 +2.98%
130+
Examples/decode/twitter100/strict 1.51e-3 1.51e-3 -0.20%
131+
```
132+
133+
Run `./bench.sh help` for more details.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2011, MailRank, Inc.
1+
Copyright (c) 2011, MailRank, Inc. 2014-2020 Aeson project contributors
22

33
All rights reserved.
44

aeson.cabal

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ extra-source-files:
3535
benchmarks/json-data/*.json
3636
cbits/*.c
3737
changelog.md
38-
examples/*.cabal
39-
examples/*.hs
40-
examples/Twitter/*.hs
4138
ffi/Data/Aeson/Parser/*.hs
4239
include/*.h
4340
tests/JSONTestSuite/test_parsing/*.json

0 commit comments

Comments
 (0)