Skip to content

Commit 625b90e

Browse files
KDr2yebai
authored andcommitted
Run benchmark on Travis-CI (#816)
* run benchmark on Travis * send bm report from Travis * Update .travis.yml
1 parent c3f5c49 commit 625b90e

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
- env: STAGE=numerical
99
- env: STAGE=stan
1010
- env: STAGE=dynamichmc
11+
- env: STAGE=benchmark
1112
include:
1213
- stage: test
1314
os: linux
@@ -108,6 +109,12 @@ jobs:
108109
- julia -e 'using Pkg, Turing;
109110
cd(joinpath(dirname(pathof(Turing)), ".."));
110111
include(joinpath("docs", "make.jl"))'
112+
- stage: benchmark
113+
julia: 1.1
114+
os: linux
115+
env: STAGE=benchmark
116+
script:
117+
- julia ./benchmarks/runbenchmarks.jl
111118
after_success:
112119
- julia -e 'if get(ENV, "STAGE", "") == "test"
113120
using Pkg; cd(Pkg.dir("Turing")); Pkg.add("Coverage");

benchmarks/runbenchmarks.jl

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Dates
2+
3+
BASE_BRANCH = "master"
4+
CURRENT_BRANCH = strip(read(`git rev-parse --abbrev-ref HEAD`, String))
5+
6+
if get(ENV, "TRAVIS", "false") == "true"
7+
if get(ENV, "TRAVIS_PULL_REQUEST", "false") == "true"
8+
CURRENT_BRANCH = get(ENV, "TRAVIS_PULL_REQUEST_BRANCH")
9+
exit(0)
10+
else
11+
CURRENT_BRANCH = get(ENV, "TRAVIS_BRANCH", "master")
12+
end
13+
end
14+
15+
SANTI_BR_NAME = 0
16+
COMMIT_SHA = strip(read(`git rev-parse HEAD`, String))
17+
COMMIT_SHA_7 = COMMIT_SHA[1:7]
18+
TIME = Dates.format(now(), "YYYYmmddHHMM")
19+
BM_JOB_NAME="BMCI-$(SANTI_BR_NAME)-$(COMMIT_SHA_7)-$(TIME)"
20+
21+
run(`git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'`)
22+
run(`git fetch --all --unshallow`)
23+
24+
run(`git clone https://github.com/TuringLang/TuringBenchmarks.git ../TuringBenchmarks`)
25+
26+
delete!(ENV, "JULIA_PROJECT")
27+
28+
code_pre = """using Pkg
29+
# Pkg.instantiate()
30+
try pkg"develop ." catch end
31+
try pkg"develop ." catch end
32+
try pkg"build Turing" catch end
33+
using Turing
34+
try pkg"develop ../TuringBenchmarks" catch end
35+
try pkg"develop ../TuringBenchmarks" catch end
36+
pkg"add SpecialFunctions"
37+
using TuringBenchmarks
38+
"""
39+
40+
code_run = """using TuringBenchmarks.Runner
41+
Runner.run_bm_on_travis("$BM_JOB_NAME", ("master", "$CURRENT_BRANCH"), "$COMMIT_SHA")
42+
"""
43+
44+
run(`julia -e $code_pre`)
45+
run(`julia -e $code_run`)

0 commit comments

Comments
 (0)