Skip to content

Commit

Permalink
Merge 1f9a87e into ad3d312
Browse files Browse the repository at this point in the history
  • Loading branch information
DilumAluthge committed Aug 20, 2019
2 parents ad3d312 + 1f9a87e commit dfd9ad8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
43 changes: 29 additions & 14 deletions src/benchmarkjudgement.jl
Expand Up @@ -35,13 +35,13 @@ function Base.show(io::IO, judgement::BenchmarkJudgement)
base.julia_commit[1:6])
end

function export_markdown(file::String, results::BenchmarkJudgement)
function export_markdown(file::String, results::BenchmarkJudgement; kwargs...)
open(file, "w") do f
export_markdown(f, results)
export_markdown(f, results; kwargs...)
end
end

function export_markdown(io::IO, judgement::BenchmarkJudgement)
function export_markdown(io::IO, judgement::BenchmarkJudgement; export_invariants::Bool = false)
target, baseline = judgement.target_results, judgement.baseline_results
function env_strs(res)
return if isempty(benchmarkconfig(res).env)
Expand Down Expand Up @@ -90,21 +90,36 @@ function export_markdown(io::IO, judgement::BenchmarkJudgement)
_update_col_widths!(cw, ids, t)
end

print(io, """
## Results
A ratio greater than `1.0` denotes a possible regression (marked with $(_REGRESS_MARK)), while a ratio less
than `1.0` denotes a possible improvement (marked with $(_IMPROVE_MARK)). Only significant results - results
that indicate possible regressions or improvements - are shown below (thus, an empty table means that all
benchmark results remained invariant between builds).
if export_invariants
print(io, """
## Results
A ratio greater than `1.0` denotes a possible regression (marked with $(_REGRESS_MARK)), while a ratio less
than `1.0` denotes a possible improvement (marked with $(_IMPROVE_MARK)). All results are shown below.
| ID$(" "^(cw[1]-2)) | time ratio$(" "^(cw[2]-10)) | memory ratio$(" "^(cw[3]-12)) |
|---$("-"^(cw[1]-2))-|-----------$("-"^(cw[2]-10))-|-------------$("-"^(cw[3]-12))-|
""")
| ID$(" "^(cw[1]-2)) | time ratio$(" "^(cw[2]-10)) | memory ratio$(" "^(cw[3]-12)) |
|---$("-"^(cw[1]-2))-|-----------$("-"^(cw[2]-10))-|-------------$("-"^(cw[3]-12))-|
""")

for (ids, t) in entries
if BenchmarkTools.isregression(t) || BenchmarkTools.isimprovement(t)
for (ids, t) in entries
println(io, _resultrow(ids, t, cw))
end
else
print(io, """
## Results
A ratio greater than `1.0` denotes a possible regression (marked with $(_REGRESS_MARK)), while a ratio less
than `1.0` denotes a possible improvement (marked with $(_IMPROVE_MARK)). Only significant results - results
that indicate possible regressions or improvements - are shown below (thus, an empty table means that all
benchmark results remained invariant between builds).
| ID$(" "^(cw[1]-2)) | time ratio$(" "^(cw[2]-10)) | memory ratio$(" "^(cw[3]-12)) |
|---$("-"^(cw[1]-2))-|-----------$("-"^(cw[2]-10))-|-------------$("-"^(cw[3]-12))-|
""")

for (ids, t) in entries
if BenchmarkTools.isregression(t) || BenchmarkTools.isimprovement(t)
println(io, _resultrow(ids, t, cw))
end
end
end

println(io)
Expand Down
10 changes: 8 additions & 2 deletions src/benchmarkresults.jl
Expand Up @@ -85,11 +85,17 @@ function readresults(file::String)
end

"""
export_markdown(file::String, results::Union{BenchmarkResults, BenchmarkJudgement})
export_markdown(io::IO, results::Union{BenchmarkResults, BenchmarkJudgement})
export_markdown(file::String, results::BenchmarkResults)
export_markdown(io::IO, results::BenchmarkResults)
export_markdown(file::String, results::BenchmarkJudgement; export_invariants=false)
export_markdown(io::IO, results::BenchmarkJudgement; export_invariants=false)
Writes the `results` to `file` or `io` in markdown format.
When exporting a `BenchmarkJudgement`, by default only the results corresponding to
possible regressions or improvements will be included. To also export the invariant
results, set `export_invariants=true`.
See also: [`BenchmarkResults`](@ref), [`BenchmarkJudgement`](@ref)
"""
function export_markdown(file::String, results::BenchmarkResults)
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Expand Up @@ -163,6 +163,8 @@ temp_pkg_dir(;tmp_dir = tmp_dir) do
judgement = judge(TEST_PACKAGE_NAME, "HEAD~", "HEAD", custom_loadpath=old_pkgdir)
test_structure(PkgBenchmark.benchmarkgroup(judgement))
export_markdown(stdout, judgement)
export_markdown(stdout, judgement; export_invariants = false)
export_markdown(stdout, judgement; export_invariants = true)
judgement = judge(TEST_PACKAGE_NAME, "HEAD", custom_loadpath=old_pkgdir)
test_structure(PkgBenchmark.benchmarkgroup(judgement))
end
Expand Down

0 comments on commit dfd9ad8

Please sign in to comment.