Created
May 21, 2020 10:11
-
-
Save moustachio-belvedere/637f6ff1fd41665dbba87218b3160c6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FunctionWrappers: FunctionWrapper | |
using BenchmarkTools | |
timevec = collect(0.0:1.0:1000); | |
params = [1.0, 1.0] | |
paramstupled = ([1.0, 1.0],) | |
paramsNT = (a = 1.0, b = 1.0,) | |
function G_Unpack_Single(tsing, params) | |
a, b, = params | |
a^2 + (a/b)*tsing | |
end | |
function G_Unpack_Vectorised(tvec, params) | |
a, b, = params | |
a^2 .+ (a/b)*tvec | |
end | |
@btime G_Unpack_Single.($timevec, $paramstupled) # 740.817 ns (1 allocation: 8.00 KiB) | |
@btime G_Unpack_Vectorised($timevec, $params) # 994.500 ns (2 allocations: 16.00 KiB) | |
function G_NT_Single(tsing; a, b) | |
a^2 + (a/b)*tsing | |
end | |
function G_NT_Vectorised(tvec; a, b) | |
a^2 .+ (a/b)*tvec | |
end | |
@btime G_NT_Single.($timevec; $paramsNT...) # 646.377 ns (2 allocations: 8.03 KiB) | |
@btime G_NT_Vectorised($timevec; $paramsNT...) # 1.236 μs (2 allocations: 16.00 KiB) | |
println("benchmarks done") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment