-
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.
* many changes * use JSON to save stuff since that is what BenchmarkTools does * simplify API be removing some kwargs * remove macro based API, this should exist in BenchmarkTools if we want it. * remove caching of results, too brittle * add update warning
- Loading branch information
1 parent
f48da9b
commit 4f5bf90
Showing
21 changed files
with
263 additions
and
401 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
.*.sw? | ||
docs/build | ||
benchmark/.tune.jld | ||
deps/already_showed |
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
julia 0.5 | ||
FileIO | ||
JLD | ||
julia 0.6 | ||
JSON | ||
BenchmarkTools | ||
ProgressMeter | ||
ProgressMeter |
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 |
---|---|---|
@@ -1,31 +1,26 @@ | ||
using PkgBenchmark | ||
using BenchmarkTools | ||
using UnicodePlots | ||
|
||
@benchgroup "utf8" ["string", "unicode"] begin | ||
teststr = String(join(rand(MersenneTwister(1), 'a':'d', 10^4))) | ||
@bench "replace" replace($teststr, "a", "b") | ||
@bench "join" join($teststr, $teststr) | ||
const SUITE = BenchmarkGroup() | ||
|
||
@benchgroup "plots" begin | ||
@bench "fnplot" lineplot([sin, cos], -π/2, 2pi) | ||
end | ||
end | ||
SUITE["utf8"] = BenchmarkGroup(["string", "unicode"]) | ||
teststr = String(join(rand(MersenneTwister(1), 'a':'d', 10^4))) | ||
SUITE["utf8"]["replace"] = @benchmarkable replace($teststr, "a", "b") | ||
SUITE["utf8"]["join"] = @benchmarkable join($teststr, $teststr) | ||
SUITE["utf8"]["plots"] = BenchmarkGroup() | ||
SUITE["utf8"]["plots"]["fnplot"] = @benchmarkable lineplot([sin, cos], -π/2, 2pi) | ||
|
||
@benchgroup "trigonometry" ["math", "triangles"] begin | ||
# nested groups | ||
@benchgroup "circular" begin | ||
for f in (sin, cos, tan) | ||
for x in (0.0, pi) | ||
@bench string(f), x $(f)($x) | ||
end | ||
end | ||
SUITE["trigonometry"] = BenchmarkGroup(["math", "triangles"]) | ||
SUITE["trigonometry"]["circular"] = BenchmarkGroup() | ||
for f in (sin, cos, tan) | ||
for x in (0.0, pi) | ||
SUITE["trigonometry"]["circular"][string(f), x] = @benchmarkable ($f)($x) | ||
end | ||
end | ||
|
||
@benchgroup "hyperbolic" begin | ||
for f in (sinh, cosh, tanh) | ||
for x in (0.0, pi) | ||
@bench string(f), x $(f)($x) | ||
end | ||
end | ||
SUITE["trigonometry"]["hyperbolic"] = BenchmarkGroup() | ||
for f in (sin, cos, tan) | ||
for x in (0.0, pi) | ||
SUITE["trigonometry"]["hyperbolic"][string(f), x] = @benchmarkable ($f)($x) | ||
end | ||
end |
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 @@ | ||
if !isfile(joinpath(@__DIR__, "already_showed")) | ||
print_with_color(Base.info_color(), STDERR, | ||
""" | ||
PkgBenchmark has been completely rewritten. Please see https://github.com/JuliaCI/PkgBenchmark.jl/ | ||
for updated documentation and examples. Code written for previous versions of PkgBenchmark is | ||
unlikely to still work. | ||
""") | ||
touch("already_showed") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,10 @@ | ||
# Defining a benchmark suite | ||
|
||
|
||
Benchmarks are to be written in `<PKGROOT>/benchmark/benchmarks.jl` and can be defined in two different ways: | ||
|
||
* Using the standard dictionary based interface from BenchmarkTools, as documented [here](https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md#defining-benchmark-suites). The naming convention that must be used is to name the benchmark suite variable `SUITE`. An example file using the dictionary based interface can be found [here](https://github.com/JuliaCI/PkgBenchmark.jl/blob/master/benchmark/benchmarks_dict.jl). Note that there is no need to have PkgBenchmark loaded to define the benchmark suite if the dict based interface is used. | ||
* Using the `@benchgroup` and `@bench` macros. These are analogous to `@testset` and `@test` macros, with slightly different syntax. An example file using the macro based interface can be found [here](https://github.com/JuliaCI/PkgBenchmark.jl/blob/master/benchmark/benchmarks.jl). | ||
|
||
Benchmarks are to be written in `<PKGROOT>/benchmark/benchmarks.jl` and are defined using the standard dictionary based interface from BenchmarkTools, as documented [here](https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md#defining-benchmark-suites). The naming convention that must be used is to name the benchmark suite variable `SUITE`. An example file using the dictionary based interface can be found [here](https://github.com/JuliaCI/PkgBenchmark.jl/blob/master/benchmark/benchmarks.jl). Note that there is no need to have PkgBenchmark loaded to define the benchmark suite. | ||
|
||
!!! note | ||
Running this script directly does not actually run the benchmarks, this is the job of PkgBenchmark, see the next section. | ||
|
||
## Writing benchmarks using the macro based API | ||
|
||
### `@benchgroup` | ||
|
||
`@benchgroup` defines a benchmark group. It can contain nested `@benchgroup` and `@bench` expressions. | ||
|
||
**Syntax:** | ||
|
||
```julia | ||
@benchgroup <name> [<tags>] begin | ||
<expr> | ||
end | ||
``` | ||
|
||
`<name>` is a string naming the benchmark group. `<tags>` is a vector of strings, tags for the benchmark group, and is optional. `<expr>` are expressions that can contain `@benchgroup` or `@bench` calls. | ||
|
||
### `@bench` | ||
|
||
`@bench` creates a benchmark under the current `@benchgroup`. | ||
|
||
**Syntax:** | ||
|
||
```julia | ||
@bench <name>... <expr> | ||
``` | ||
|
||
`<name>` is a name/id for the benchmark, the last argument to `@bench`, `<expr>`, is the expression to be benchmarked, and has the same [interpolation features](https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md#interpolating-values-into-benchmark-expressions) as the `@benchmarkable` macro from BenchmarkTools. | ||
|
||
### Example | ||
|
||
An example `benchmark/benchmarks.jl` script would look like: | ||
|
||
```julia | ||
using PkgBenchmark | ||
|
||
@benchgroup "utf8" ["string", "unicode"] begin | ||
teststr = UTF8String(join(rand(MersenneTwister(1), 'a':'d', 10^4))) | ||
@bench "replace" replace($teststr, "a", "b") | ||
@bench "join" join($teststr, $teststr) | ||
end | ||
|
||
@benchgroup "trigonometry" ["math", "triangles"] begin | ||
# nested groups | ||
@benchgroup "circular" begin | ||
for f in (sin, cos, tan) | ||
for x in (0.0, pi) | ||
@bench string(f), x $(f)($x) | ||
end | ||
end | ||
end | ||
|
||
@benchgroup "hyperbolic" begin | ||
for f in (sinh, cosh, tanh) | ||
for x in (0.0, pi) | ||
@bench string(f), x $(f)($x) | ||
end | ||
end | ||
end | ||
end | ||
``` | ||
|
||
## Custom requirements for benchmarks | ||
|
||
`<PKGROOT>/benchmark/REQUIRE` can contain dependencies needed to run the benchmark suite, similarly how `<PKGROOT>/benchmark/REQUIRE` can contain dependencies for the tests. |
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
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
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.