@@ -24,7 +24,7 @@ To quickly benchmark a Julia expression, use `@benchmark`:
24
24
25
25
``` julia
26
26
julia> @benchmark sin (1 )
27
- BechmarkTools . Trial: 10000 samples with 1000 evaluations.
27
+ BenchmarkTools . Trial: 10000 samples with 1000 evaluations.
28
28
Range (min … max): 1.442 ns … 53.028 ns ┊ GC (min … max): 0.00 % … 0.00 %
29
29
Time (median): 1.453 ns ┊ GC (median): 0.00 %
30
30
Time (mean ± σ): 1.462 ns ± 0.566 ns ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -45,7 +45,7 @@ julia> b = @benchmarkable sin(1); # define the benchmark with default parameters
45
45
julia> tune! (b);
46
46
47
47
julia> run (b)
48
- BechmarkTools . Trial: 10000 samples with 1000 evaluations.
48
+ BenchmarkTools . Trial: 10000 samples with 1000 evaluations.
49
49
Range (min … max): 1.442 ns … 4.308 ns ┊ GC (min … max): 0.00 % … 0.00 %
50
50
Time (median): 1.453 ns ┊ GC (median): 0.00 %
51
51
Time (mean ± σ): 1.456 ns ± 0.056 ns ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -109,7 +109,7 @@ You can interpolate values into `@benchmark` and `@benchmarkable` expressions:
109
109
``` julia
110
110
# rand(1000) is executed for each evaluation
111
111
julia> @benchmark sum (rand (1000 ))
112
- BechmarkTools . Trial: 10000 samples with 10 evaluations.
112
+ BenchmarkTools . Trial: 10000 samples with 10 evaluations.
113
113
Range (min … max): 1.153 μs … 142.253 μs ┊ GC (min … max): 0.00 % … 96.43 %
114
114
Time (median): 1.363 μs ┊ GC (median): 0.00 %
115
115
Time (mean ± σ): 1.786 μs ± 4.612 μs ┊ GC (mean ± σ): 9.58 % ± 3.70 %
@@ -123,7 +123,7 @@ BechmarkTools.Trial: 10000 samples with 10 evaluations.
123
123
# rand(1000) is evaluated at definition time, and the resulting
124
124
# value is interpolated into the benchmark expression
125
125
julia> @benchmark sum ($ (rand (1000 )))
126
- BechmarkTools . Trial: 10000 samples with 963 evaluations.
126
+ BenchmarkTools . Trial: 10000 samples with 963 evaluations.
127
127
Range (min … max): 84.477 ns … 241.602 ns ┊ GC (min … max): 0.00 % … 0.00 %
128
128
Time (median): 84.497 ns ┊ GC (median): 0.00 %
129
129
Time (mean ± σ): 85.125 ns ± 5.262 ns ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -142,7 +142,7 @@ julia> A = rand(1000);
142
142
143
143
# BAD: A is a global variable in the benchmarking context
144
144
julia> @benchmark [i* i for i in A]
145
- BechmarkTools . Trial: 10000 samples with 54 evaluations.
145
+ BenchmarkTools . Trial: 10000 samples with 54 evaluations.
146
146
Range (min … max): 889.241 ns … 29.584 μs ┊ GC (min … max): 0.00 % … 93.33 %
147
147
Time (median): 1.073 μs ┊ GC (median): 0.00 %
148
148
Time (mean ± σ): 1.296 μs ± 2.004 μs ┊ GC (mean ± σ): 14.31 % ± 8.76 %
@@ -155,7 +155,7 @@ BechmarkTools.Trial: 10000 samples with 54 evaluations.
155
155
156
156
# GOOD: A is a constant value in the benchmarking context
157
157
julia> @benchmark [i* i for i in $ A]
158
- BechmarkTools . Trial: 10000 samples with 121 evaluations.
158
+ BenchmarkTools . Trial: 10000 samples with 121 evaluations.
159
159
Range (min … max): 742.455 ns … 11.846 μs ┊ GC (min … max): 0.00 % … 88.05 %
160
160
Time (median): 909.959 ns ┊ GC (median): 0.00 %
161
161
Time (mean ± σ): 1.135 μs ± 1.366 μs ┊ GC (mean ± σ): 16.94 % ± 12.58 %
@@ -221,7 +221,7 @@ julia> b = @benchmarkable sort!(y) setup=(y = copy($x))
221
221
Benchmark (evals= 1 , seconds= 5.0 , samples= 10000 )
222
222
223
223
julia> run (b)
224
- BechmarkTools . Trial: 819 samples with 1 evaluations.
224
+ BenchmarkTools . Trial: 819 samples with 1 evaluations.
225
225
Range (min … max): 5.983 ms … 6.954 ms ┊ GC (min … max): 0.00 % … 0.00 %
226
226
Time (median): 6.019 ms ┊ GC (median): 0.00 %
227
227
Time (mean ± σ): 6.029 ms ± 46.222 μs ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -242,7 +242,7 @@ Note that the `setup` and `teardown` phases are **executed for each sample, not
242
242
It's possible for LLVM and Julia's compiler to perform optimizations on ` @benchmarkable ` expressions. In some cases, these optimizations can elide a computation altogether, resulting in unexpectedly "fast" benchmarks. For example, the following expression is non-allocating:
243
243
``` julia
244
244
julia> @benchmark (view (a, 1 : 2 , 1 : 2 ); 1 ) setup= (a = rand (3 , 3 ))
245
- BechmarkTools . Trial: 10000 samples with 1000 evaluations.
245
+ BenchmarkTools . Trial: 10000 samples with 1000 evaluations.
246
246
Range (min … max): 2.885 ns … 14.797 ns ┊ GC (min … max): 0.00 % … 0.00 %
247
247
Time (median): 2.895 ns ┊ GC (median): 0.00 %
248
248
Time (mean ± σ): 3.320 ns ± 0.909 ns ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -258,7 +258,7 @@ Note, however, that this does not mean that `view(a, 1:2, 1:2)` is non-allocatin
258
258
259
259
``` julia
260
260
julia> @benchmark view (a, 1 : 2 , 1 : 2 ) setup= (a = rand (3 , 3 ))
261
- BechmarkTools . Trial: 10000 samples with 1000 evaluations.
261
+ BenchmarkTools . Trial: 10000 samples with 1000 evaluations.
262
262
Range (min … max): 3.175 ns … 18.314 ns ┊ GC (min … max): 0.00 % … 0.00 %
263
263
Time (median): 3.176 ns ┊ GC (median): 0.00 %
264
264
Time (mean ± σ): 3.262 ns ± 0.882 ns ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -307,7 +307,7 @@ Running a benchmark produces an instance of the `Trial` type:
307
307
308
308
``` julia
309
309
julia> t = @benchmark eigen (rand (10 , 10 ))
310
- BechmarkTools . Trial: 10000 samples with 1 evaluations.
310
+ BenchmarkTools . Trial: 10000 samples with 1 evaluations.
311
311
Range (min … max): 26.549 μs … 1.503 ms ┊ GC (min … max): 0.00 % … 93.21 %
312
312
Time (median): 30.818 μs ┊ GC (median): 0.00 %
313
313
Time (mean ± σ): 31.777 μs ± 25.161 μs ┊ GC (mean ± σ): 1.31 % ± 1.63 %
0 commit comments