You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/snippets/benchmark/julia/benchmark.jl
+41-12Lines changed: 41 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,9 @@
3
3
import BenchmarkTools
4
4
5
5
# Benchmark variables:
6
-
name ="TODO";
7
6
repeats =3;
7
+
samples =1e6;
8
+
count =0;
8
9
9
10
"""
10
11
print_version()
@@ -73,7 +74,7 @@ function print_results( iterations, elapsed )
73
74
end
74
75
75
76
"""
76
-
benchmark()
77
+
benchmark( expr )
77
78
78
79
Run a benchmark.
79
80
@@ -83,14 +84,18 @@ Run a benchmark.
83
84
* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation.
84
85
* The elapsed time is in seconds.
85
86
87
+
# Arguments
88
+
89
+
* `expr`: expression to benchmark
90
+
86
91
# Examples
87
92
88
93
``` julia
89
-
julia> out = benchmark();
94
+
julia> out = benchmark( :( sin( 3.14 ) ) );
90
95
```
91
96
"""
92
-
functionbenchmark()
93
-
t = BenchmarkTools.@benchmarkTODO samples=1e6
97
+
functionbenchmark( expr )
98
+
t =eval( :( BenchmarkTools.@benchmark$expr samples=$samples ) )
94
99
95
100
# Compute the total "elapsed" time and convert from nanoseconds to seconds:
0 commit comments