Skip to content

Commit

Permalink
Run multi-thread benchmarks in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jan 5, 2020
1 parent b74c36f commit 8c583be
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
16 changes: 14 additions & 2 deletions .travis.yml
Expand Up @@ -38,8 +38,7 @@ jobs:
- julia -e 'using Run; Run.prepare("test/environments/jl10")'
script:
- julia -e 'using Run; Run.test(project="test/environments/jl10")'
- name: "Benchmark"
julia: 1.1
- name: "Benchmark (Sequential)"
os: linux
install:
- julia -e 'using Run; Run.prepare("benchmark")'
Expand All @@ -52,6 +51,19 @@ jobs:
- julia -e 'using Run; Run.script("benchmark/pprintjudge.jl")'
after_success: skip
if: NOT (branch = master)
- name: "Benchmark (Multi-thread)"
os: linux
install:
- julia -e 'using Run; Run.prepare("benchmark")'
before_script:
- git fetch origin '+refs/heads/master:refs/remotes/origin/master'
- git branch master origin/master
# Run benchmark outside `script` so that it's hidden by default:
- julia -e 'using Run; Run.script("benchmark/runjudge_multi_thread.jl")'
script:
- julia -e 'using Run; Run.script("benchmark/pprintjudge_multi_thread.jl")'
after_success: skip
if: NOT (branch = master)
- stage: "Documentation"
julia: 1.3
os: linux
Expand Down
File renamed without changes.
@@ -1,6 +1,6 @@
module BenchWords
using BenchmarkTools
include("../examples/words.jl")
include("../../examples/words.jl")

suite = BenchmarkGroup()

Expand Down
16 changes: 16 additions & 0 deletions benchmark/multi-thread/benchmarks.jl
@@ -0,0 +1,16 @@
if lowercase(get(ENV, "CI", "false")) == "true"
@info "Executing in CI. Instantiating benchmark environment..."
using Pkg
Pkg.activate(dirname(@__DIR__))
Pkg.instantiate()
end

using BenchmarkTools
SUITE = BenchmarkGroup()
for file in readdir(@__DIR__)
file == "bench_words.jl" && continue
if startswith(file, "bench_") && endswith(file, ".jl")
SUITE[file[length("bench_") + 1:end - length(".jl")]] =
include(file)
end
end
14 changes: 14 additions & 0 deletions benchmark/pprintjudge_multi_thread.jl
@@ -0,0 +1,14 @@
using PkgBenchmark
include("pprinthelper.jl")
benchdir = joinpath(@__DIR__, "multi-thread")
group_target = PkgBenchmark.readresults(joinpath(benchdir, "result-target.json"))
group_baseline = PkgBenchmark.readresults(joinpath(benchdir, "result-baseline.json"))
judgement = judge(group_target, group_baseline)

displayresult(judgement)

printnewsection("Target result")
displayresult(group_target)

printnewsection("Baseline result")
displayresult(group_baseline)
36 changes: 36 additions & 0 deletions benchmark/runjudge_multi_thread.jl
@@ -0,0 +1,36 @@
using PkgBenchmark

mkconfig(; kwargs...) =
BenchmarkConfig(
env = Dict(
"JULIA_NUM_THREADS" => "2",
);
kwargs...
)

progressoptions =
if lowercase(get(ENV, "CI", "false")) == "true"
(dt = 60 * 9.0,)
else
NamedTuple()
end

benchdir = joinpath(@__DIR__, "multi-thread")

group_target = benchmarkpkg(
dirname(@__DIR__),
mkconfig(),
script = joinpath(benchdir, "benchmarks.jl"),
progressoptions = progressoptions,
resultfile = joinpath(benchdir, "result-target.json"),
)

group_baseline = benchmarkpkg(
dirname(@__DIR__),
mkconfig(id = "master"),
script = joinpath(benchdir, "benchmarks.jl"),
progressoptions = progressoptions,
resultfile = joinpath(benchdir, "result-baseline.json"),
)

judgement = judge(group_target, group_baseline)

0 comments on commit 8c583be

Please sign in to comment.