|
| 1 | +VERSION < v"0.5" && warn("This example uses dot broadcast syntax "* |
| 2 | + "and may not work on Julia versions lower"* |
| 3 | + " than v0.5!") |
| 4 | + |
1 | 5 | using BenchmarkTools
|
2 | 6 |
|
3 | 7 | # Define a parent BenchmarkGroup to contain our suite
|
4 | 8 | const suite = BenchmarkGroup()
|
5 | 9 |
|
6 | 10 | # Add some child groups to our benchmark suite.
|
7 | 11 | suite["string"] = BenchmarkGroup(["unicode"])
|
8 |
| -suite["trigonometry"] = BenchmarkGroup(["math", "triangles"]) |
| 12 | +suite["trig"] = BenchmarkGroup(["math", "triangles"]) |
| 13 | +suite["dot"] = BenchmarkGroup(["broadcast", "elementwise"]) |
9 | 14 |
|
10 | 15 | # This string will be the same every time because we're seeding the RNG
|
11 | 16 | teststr = join(rand(MersenneTwister(1), 'a':'d', 10^4))
|
12 | 17 |
|
13 | 18 | # Add some benchmarks to the "utf8" group
|
14 |
| -suite["string"]["replace"] = @benchmarkable replace($teststr, "a", "b") |
15 |
| -suite["string"]["join"] = @benchmarkable join($teststr, $teststr) |
| 19 | +suite["string"]["replace"] = @benchmarkable replace($teststr, "a", "b") seconds=Float64(π) |
| 20 | +suite["string"]["join"] = @benchmarkable join($teststr, $teststr) samples=42 |
16 | 21 |
|
17 |
| -# Add some benchmarks to the "trigonometry" group |
| 22 | +# Add some benchmarks to the "trig"/"dot" group |
18 | 23 | for f in (sin, cos, tan)
|
19 | 24 | for x in (0.0, pi)
|
20 |
| - suite["trigonometry"][string(f), x] = @benchmarkable $(f)($x) |
| 25 | + suite["trig"][string(f), x] = @benchmarkable $(f)($x) |
| 26 | + suite["dot"][string(f), x] = @benchmarkable $(f).([$x, $x, $x]) |
21 | 27 | end
|
22 | 28 | end
|
23 | 29 |
|
|
27 | 33 | paramspath = joinpath(dirname(@__FILE__), "params.jld")
|
28 | 34 |
|
29 | 35 | if isfile(paramspath)
|
30 |
| - loadparams!(suite, BenchmarkTools.load(paramspath, "suite"), :evals, :samples); |
| 36 | + loadparams!(suite, BenchmarkTools.load(paramspath, "suite"), :evals); |
31 | 37 | else
|
32 | 38 | tune!(suite)
|
33 | 39 | BenchmarkTools.save(paramspath, "suite", params(suite));
|
|
0 commit comments