diff --git a/.travis.yml b/.travis.yml index d1975b1cb3..9a9345546b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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")' @@ -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 diff --git a/benchmark/bench_unordered.jl b/benchmark/multi-thread/bench_unordered.jl similarity index 100% rename from benchmark/bench_unordered.jl rename to benchmark/multi-thread/bench_unordered.jl diff --git a/benchmark/bench_words.jl b/benchmark/multi-thread/bench_words.jl similarity index 93% rename from benchmark/bench_words.jl rename to benchmark/multi-thread/bench_words.jl index 97bbb8defc..cb5345f7c6 100644 --- a/benchmark/bench_words.jl +++ b/benchmark/multi-thread/bench_words.jl @@ -1,6 +1,6 @@ module BenchWords using BenchmarkTools -include("../examples/words.jl") +include("../../examples/words.jl") suite = BenchmarkGroup() diff --git a/benchmark/multi-thread/benchmarks.jl b/benchmark/multi-thread/benchmarks.jl new file mode 100644 index 0000000000..417622d2c2 --- /dev/null +++ b/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 diff --git a/benchmark/pprintjudge_multi_thread.jl b/benchmark/pprintjudge_multi_thread.jl new file mode 100644 index 0000000000..ea24569707 --- /dev/null +++ b/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) diff --git a/benchmark/runjudge_multi_thread.jl b/benchmark/runjudge_multi_thread.jl new file mode 100644 index 0000000000..985eb9eeb0 --- /dev/null +++ b/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)