@@ -24,7 +24,7 @@ To quickly benchmark a Julia expression, use `@benchmark`:
2424
2525``` julia
2626julia> @benchmark sin (1 )
27- BechmarkTools . Trial: 10000 samples with 1000 evaluations.
27+ BenchmarkTools . Trial: 10000 samples with 1000 evaluations.
2828 Range (min … max): 1.442 ns … 53.028 ns ┊ GC (min … max): 0.00 % … 0.00 %
2929 Time (median): 1.453 ns ┊ GC (median): 0.00 %
3030 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
4545julia> tune! (b);
4646
4747julia> run (b)
48- BechmarkTools . Trial: 10000 samples with 1000 evaluations.
48+ BenchmarkTools . Trial: 10000 samples with 1000 evaluations.
4949 Range (min … max): 1.442 ns … 4.308 ns ┊ GC (min … max): 0.00 % … 0.00 %
5050 Time (median): 1.453 ns ┊ GC (median): 0.00 %
5151 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:
109109``` julia
110110# rand(1000) is executed for each evaluation
111111julia> @benchmark sum (rand (1000 ))
112- BechmarkTools . Trial: 10000 samples with 10 evaluations.
112+ BenchmarkTools . Trial: 10000 samples with 10 evaluations.
113113 Range (min … max): 1.153 μs … 142.253 μs ┊ GC (min … max): 0.00 % … 96.43 %
114114 Time (median): 1.363 μs ┊ GC (median): 0.00 %
115115 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.
123123# rand(1000) is evaluated at definition time, and the resulting
124124# value is interpolated into the benchmark expression
125125julia> @benchmark sum ($ (rand (1000 )))
126- BechmarkTools . Trial: 10000 samples with 963 evaluations.
126+ BenchmarkTools . Trial: 10000 samples with 963 evaluations.
127127 Range (min … max): 84.477 ns … 241.602 ns ┊ GC (min … max): 0.00 % … 0.00 %
128128 Time (median): 84.497 ns ┊ GC (median): 0.00 %
129129 Time (mean ± σ): 85.125 ns ± 5.262 ns ┊ GC (mean ± σ): 0.00 % ± 0.00 %
@@ -142,7 +142,7 @@ julia> A = rand(1000);
142142
143143# BAD: A is a global variable in the benchmarking context
144144julia> @benchmark [i* i for i in A]
145- BechmarkTools . Trial: 10000 samples with 54 evaluations.
145+ BenchmarkTools . Trial: 10000 samples with 54 evaluations.
146146 Range (min … max): 889.241 ns … 29.584 μs ┊ GC (min … max): 0.00 % … 93.33 %
147147 Time (median): 1.073 μs ┊ GC (median): 0.00 %
148148 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.
155155
156156# GOOD: A is a constant value in the benchmarking context
157157julia> @benchmark [i* i for i in $ A]
158- BechmarkTools . Trial: 10000 samples with 121 evaluations.
158+ BenchmarkTools . Trial: 10000 samples with 121 evaluations.
159159 Range (min … max): 742.455 ns … 11.846 μs ┊ GC (min … max): 0.00 % … 88.05 %
160160 Time (median): 909.959 ns ┊ GC (median): 0.00 %
161161 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))
221221Benchmark (evals= 1 , seconds= 5.0 , samples= 10000 )
222222
223223julia> run (b)
224- BechmarkTools . Trial: 819 samples with 1 evaluations.
224+ BenchmarkTools . Trial: 819 samples with 1 evaluations.
225225 Range (min … max): 5.983 ms … 6.954 ms ┊ GC (min … max): 0.00 % … 0.00 %
226226 Time (median): 6.019 ms ┊ GC (median): 0.00 %
227227 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
242242It'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:
243243``` julia
244244julia> @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.
246246 Range (min … max): 2.885 ns … 14.797 ns ┊ GC (min … max): 0.00 % … 0.00 %
247247 Time (median): 2.895 ns ┊ GC (median): 0.00 %
248248 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
258258
259259``` julia
260260julia> @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.
262262 Range (min … max): 3.175 ns … 18.314 ns ┊ GC (min … max): 0.00 % … 0.00 %
263263 Time (median): 3.176 ns ┊ GC (median): 0.00 %
264264 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:
307307
308308``` julia
309309julia> t = @benchmark eigen (rand (10 , 10 ))
310- BechmarkTools . Trial: 10000 samples with 1 evaluations.
310+ BenchmarkTools . Trial: 10000 samples with 1 evaluations.
311311 Range (min … max): 26.549 μs … 1.503 ms ┊ GC (min … max): 0.00 % … 93.21 %
312312 Time (median): 30.818 μs ┊ GC (median): 0.00 %
313313 Time (mean ± σ): 31.777 μs ± 25.161 μs ┊ GC (mean ± σ): 1.31 % ± 1.63 %
0 commit comments