Skip to content

Commit 7584a46

Browse files
stevengjjrevels
authored andcommitted
add convert benchmarks (#32)
* add convert benchmarks based on 18954 * splice arguments * shrink benchmark size
1 parent 9541cac commit 7584a46

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/array/ArrayBenchmarks.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,26 @@ g["boolarray_true_load!"] = @benchmarkable perf_true_load!($boolarr)
213213
g["bitarray_true_fill!"] = @benchmarkable fill!($bitarr, true)
214214
g["boolarray_true_fill!"] = @benchmarkable fill!($boolarr, true)
215215

216+
217+
####################################
218+
# Float to Int conversion (#18954) #
219+
####################################
220+
221+
function perf_convert!(a, x)
222+
for i=1:length(x)
223+
a[i] = x[i]
224+
end
225+
return a
226+
end
227+
228+
x_int = rand(1:1000000,100,100)
229+
x_float = 1.0 * x_int
230+
x_complex = x_float .+ 0.0im
231+
232+
g = addgroup!(SUITE, "convert", ["Int"])
233+
g["Int", "Float64"] = @benchmarkable perf_convert!($x_int, $x_float)
234+
g["Float64", "Int"] = @benchmarkable perf_convert!($x_float, $x_int)
235+
g["Complex{Float64}", "Int"] = @benchmarkable perf_convert!($x_complex, $x_int)
236+
g["Int", "Complex{Float64}"] = @benchmarkable perf_convert!($x_int, $x_complex)
237+
216238
end # module

0 commit comments

Comments
 (0)