Benchmarks.jl icon indicating copy to clipboard operation
Benchmarks.jl copied to clipboard

@benchmark on functions with kwargs fails

Open jiahao opened this issue 10 years ago • 4 comments

Some time in the last few weeks this stopped working:

julia> svds(randn(10,10), nsv=3);

julia> @benchmark svds(randn(10,10), nsv=3)
ERROR: MethodError: `*` has no method matching *(::Int64, ::Symbol)
Closest candidates are:
  *(::Any, ::Any, ::Any, ::Any...)
  *(::Number)
  *(::Number, ::Bool)
  ...
 in abstract_call at ./inference.jl:873
 in abstract_eval_call at ./inference.jl:934
 in abstract_eval at ./inference.jl:961
 in typeinf_uncached at ./inference.jl:1622
 in typeinf at ./inference.jl:1339
 in typeinf at ./inference.jl:1289
 in abstract_call_gf at ./inference.jl:737
 in abstract_call at ./inference.jl:879
 in abstract_eval_call at ./inference.jl:934
 in abstract_eval at ./inference.jl:961
 in abstract_interpret at ./inference.jl:1110
 in typeinf_uncached at ./inference.jl:1549
 in typeinf at ./inference.jl:1339
 in typeinf at ./inference.jl:1289
 in abstract_call_gf at ./inference.jl:737
 in abstract_call at ./inference.jl:879
 in abstract_eval_call at ./inference.jl:934
 in abstract_eval at ./inference.jl:961
 in typeinf_uncached at ./inference.jl:1622
 in typeinf at ./inference.jl:1339
 in typeinf_ext at ./inference.jl:1283
 in execute at /afs/csail.mit.edu/u/j/jiahao/.julia/v0.4/Benchmarks/src/execute.jl:47
 in execute at /afs/csail.mit.edu/u/j/jiahao/.julia/v0.4/Benchmarks/src/execute.jl:42

jiahao avatar Oct 14 '15 22:10 jiahao

Yeah, this was my doing. Deconstructing and reconstructing these keyword arguments will be a pain.

mbauman avatar Oct 14 '15 23:10 mbauman

I seem to still have problems with keywords:

# data
N = 10^5
N_queries = 10^4
dim = 3
k = 1
data = rand(dim, N)

# Normal call works
julia> KDTree(data; leafsize = 5, reorder = true)
NearestNeighbors.KDTree{Float64,Distances.Euclidean}
  Number of points: 100000
  Dimensions: 3
  Metric: Distances.Euclidean()
  Reordered: true

#Benchmark without keywords work:
julia> @benchmark KDTree(data)
================ Benchmark Results ========================
     Time per evaluation: 25.86 ms [25.26 ms, 26.45 ms]
Proportion of time in GC: 1.65% [0.00%, 3.72%]
        Memory allocated: 4.27 mb
   Number of allocations: 10015 allocations
       Number of samples: 100
   Number of evaluations: 100
 Time spent benchmarking: 2.65 s

# Benchmark with keyword errors
julia> @benchmark KDTree(data; leafsize = 5, reorder = true)
ERROR: error compiling ##7369: unsupported or misplaced expression "parameters" in function ##7369
 in execute at C:\Users\kcarl\.julia\v0.4\Benchmarks\src\execute.jl:47
 in execute at C:\Users\kcarl\.julia\v0.4\Benchmarks\src\execute.jl:42

KristofferC avatar Nov 16 '15 21:11 KristofferC

Try it with a comma instead of a semicolon… I think that gets parsed differently. We should support both, though. I'm not sure when I'll get to this.

mbauman avatar Nov 16 '15 21:11 mbauman

Comma works perfectly. Thanks for a quick answer! :)

KristofferC avatar Nov 16 '15 21:11 KristofferC