Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
running with @benchmarks throws an error but runs fine without
function get_all_tracks_info(db, track_id, ca; num=49)
res = vcat(SQLite.query(db, sr"""
SELECT track_id, track_index, author_id, genre, 1 AS listened
FROM tracks
WHERE track_id = ?;""",
values=[track_id]),
SQLite.query(db, sr"""
SELECT track_id, track_index, author_id, genre, 0 AS listened
FROM tracks
WHERE created_at < ? AND track_id <> ?
ORDER BY RANDOM() LIMIT ?;""",
values=[ca, track_id, num]))
sort!(res, :track_id)
return res
end
# db is a SQLite db
# focal_track is of type Int64
# time is a Float64
@time get_all_tracks_info(db, focal_track, time; num=100) # runs fine
@benchmark get_all_tracks_info($(db), $(focal_track), $(time); num=100) # throws below error
#=
ERROR: MethodError: objects of type Float64 are not callable
Stacktrace:
[1] #_run#105(::Bool, ::String, ::Array{Any,1}, ::Function, ::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}, ::BenchmarkTools.Parameters) at /afs/.ir/users/j/s/jsams/.julia/v0.6/BenchmarkTools/src/execution.jl:347
[2] (::BenchmarkTools.#kw##_run)(::Array{Any,1}, ::BenchmarkTools.#_run, ::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}, ::BenchmarkTools.Parameters) at ./<missing>:0
[3] anonymous at ./<missing>:?
[4] #run_result#19(::Array{Any,1}, ::Function, ::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}, ::BenchmarkTools.Parameters) at /afs/.ir/users/j/s/jsams/.julia/v0.6/BenchmarkTools/src/execution.jl:44
[5] (::BenchmarkTools.#kw##run_result)(::Array{Any,1}, ::BenchmarkTools.#run_result, ::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}, ::BenchmarkTools.Parameters) at ./<missing>:0
[6] #run#21(::Array{Any,1}, ::Function, ::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}, ::BenchmarkTools.Parameters) at /afs/.ir/users/j/s/jsams/.julia/v0.6/BenchmarkTools/src/execution.jl:67
[7] (::Base.#kw##run)(::Array{Any,1}, ::Base.#run, ::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}, ::BenchmarkTools.Parameters) at ./<missing>:0
[8] warmup(::BenchmarkTools.Benchmark{Symbol("##benchmark#960")}) at /afs/.ir/users/j/s/jsams/.julia/v0.6/BenchmarkTools/src/execution.jl:100
=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment