Skip to content

specialization on function argument not occuring as expected #19137

Closed

Description

julia> VERSION
v"0.6.0-dev.1079"

julia> notricks(f, x) = broadcast(f, x)
notricks (generic function with 1 method)

julia> forcespec{TF}(f::TF, x) = broadcast(f, x)
forcespec (generic function with 1 method)

julia> x = rand(10^2);

julia> using BenchmarkTools

julia> @benchmark notricks($abs, $x)
BenchmarkTools.Trial:
  samples:          10000
  evals/sample:     1
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  1.91 kb
  allocs estimate:  28
  minimum time:     19.00 μs (0.00% GC)
  median time:      20.26 μs (0.00% GC)
  mean time:        22.96 μs (0.00% GC)
  maximum time:     295.82 μs (0.00% GC)

julia> @benchmark forcespec($abs, $x)
BenchmarkTools.Trial:
  samples:          10000
  evals/sample:     849
  time tolerance:   5.00%
  memory tolerance: 1.00%
  memory estimate:  912.00 bytes
  allocs estimate:  2
  minimum time:     146.00 ns (0.00% GC)
  median time:      157.00 ns (0.00% GC)
  mean time:        201.21 ns (14.08% GC)
  maximum time:     1.63 μs (82.76% GC)

See #18975 (comment) for the original discussion and ref. #19065. Best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions