-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
437 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Comparing commits | ||
|
||
You can use `judge` to compare benchmark results of two versions of the package. | ||
|
||
```@docs | ||
judge | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Export to markdown | ||
|
||
It is possible to export results from [`PkgBenchmark.BenchmarkResults`](@ref) using the function `export_markdown` | ||
|
||
```@docs | ||
export_markdown | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
```@index | ||
Pages = ["ref.md"] | ||
Modules = [PkgBenchmark] | ||
``` | ||
|
||
```@autodocs | ||
Modules = [PkgBenchmark] | ||
Private = false | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
```@meta | ||
DocTestSetup = quote | ||
using PkgBenchmark | ||
end | ||
``` | ||
|
||
# Running a benchmark suite | ||
|
||
Use `benchmarkpkg` to run benchmarks defined in a suite as defined in the previous section. | ||
|
||
```@docs | ||
benchmarkpkg | ||
``` | ||
|
||
The results of a benchmark is returned as a `BenchmarkResult` | ||
|
||
```@docs | ||
PkgBenchmark.BenchmarkResults | ||
``` | ||
|
||
## More advanced customization | ||
|
||
Instead of passing a commit, branch etc. as a `String` to `benchmarkpkg`, a [`BenchmarkConfig`](@ref) can be passed. | ||
This object contains the package commit, julia command, and what environment variables will | ||
be used when benchmarking. The default values can be seen by using the default constructor | ||
|
||
```julia-repl | ||
julia> BenchmarkConfig() | ||
BenchmarkConfig: | ||
id: nothing | ||
juliacmd: `/home/user/julia/julia` | ||
env: | ||
``` | ||
|
||
The `id` is a commit, branch etc as described in the previous section. An `id` with value `nothing` means that the current state of the package will be benchmarked. | ||
The default value of `juliacmd` is `joinpath(JULIA_HOME, Base.julia_exename()` which is the command to run the julia executable without any command line arguments. | ||
|
||
To instead benchmark the branch `PR`, using the julia command `julia -O3` | ||
with the environment variable `JULIA_NUM_THREADS` set to `4`, the config would be created as | ||
|
||
```jldoctest | ||
julia> config = BenchmarkConfig(id = "PR", | ||
juliacmd = `julia -O3`, | ||
env = Dict("JULIA_NUM_THREADS" => 4)) | ||
BenchmarkConfig: | ||
id: PR | ||
juliacmd: `julia -O3` | ||
env: JULIA_NUM_THREADS => 4 | ||
``` | ||
|
||
To benchmark the package with the config, call [`benchmarkpkg`](@ref) as e.g. | ||
|
||
```julia | ||
benchmark("Tensors", config) | ||
``` | ||
|
||
!!! info | ||
The `id` keyword to the `BenchmarkConfig` does not have to be a branch, it can be most things that git can understand, for example a commit id | ||
or a tag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
""" | ||
BenchmarkConfig | ||
A `BenchmarkConfig` contains the configuration for the benchmarks to be executed | ||
by [`benchmarkpkg`](@ref). | ||
This includes the following: | ||
* The commit of the package the benchmarks are run on. | ||
* What julia command should be run, i.e. the path to the Julia executable and | ||
the command flags used (e.g. optimization level with `-O`). | ||
* Custom environment variables (e.g. `JULIA_NUM_THREADS`). | ||
""" | ||
struct BenchmarkConfig | ||
id::Union{String,Void} | ||
juliacmd::Cmd | ||
env::Dict{String,Any} | ||
end | ||
|
||
function _hash(pkgname::String, pkgcommit::String, juliacommit, config::BenchmarkConfig) | ||
return hash(pkgname, | ||
hash(juliacommit, | ||
hash(length(config.juliacmd) > 1 ? config.juliacmd[2:end] : 0, | ||
hash(pkgcommit, | ||
hash(config.env))))) | ||
end | ||
|
||
""" | ||
BenchmarkConfig(;id::Union{String, Void} = nothing, | ||
juliacmd::Cmd = `$(joinpath(JULIA_HOME, Base.julia_exename()))`, | ||
env::Dict{String, Any} = Dict{String, Any}()) | ||
Creates a `BenchmarkConfig` from the following keyword arguments: | ||
* `id` - A git identifier like a commit, branch, tag, "HEAD", "HEAD~1" etc. | ||
If `id == nothing` then benchmark will be done on the current state | ||
of the repo (even if it is dirty). | ||
* `juliacmd` - Used to exectue the benchmarks, defaults to the julia executable | ||
that the Pkgbenchmark-functions are called from. Can also include command flags. | ||
* `env` - Contains custom environment variables that will be active when the | ||
benchmarks are run. | ||
# Examples | ||
```julia | ||
BenchmarkConfig(id = "performance_improvements", | ||
juliacmd = `julia -O3`, | ||
env = Dict("JULIA_NUM_THREADS" => 4)) | ||
``` | ||
""" | ||
function BenchmarkConfig(;id::Union{String,Void} = nothing, | ||
|
||
juliacmd::Cmd = `$(joinpath(JULIA_HOME, Base.julia_exename()))`, | ||
env::Dict = Dict{String,Any}()) | ||
BenchmarkConfig(id, juliacmd, env) | ||
end | ||
|
||
BenchmarkConfig(cfg::BenchmarkConfig) = cfg | ||
BenchmarkConfig(str::String) = BenchmarkConfig(id = str) | ||
BenchmarkConfig(::Void) = BenchmarkConfig() | ||
|
||
const INDENT = " " | ||
|
||
function Base.show(io::IO, bcfg::BenchmarkConfig) | ||
println(io, "BenchmarkConfig:") | ||
println(io, INDENT, "id: ", bcfg.id) | ||
println(io, INDENT, "juliacmd: ", bcfg.juliacmd) | ||
print(io, INDENT, "env: ") | ||
if !isempty(bcfg.env) | ||
first = true | ||
for (k, v) in bcfg.env | ||
if !first | ||
println(io) | ||
print(io, INDENT, " "^strwidth("env: ")) | ||
end | ||
first = false | ||
print(io, k, " => ", v) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.