Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtyping test slows code down #23465

Closed
cstjean opened this issue Aug 26, 2017 · 1 comment
Closed

Subtyping test slows code down #23465

cstjean opened this issue Aug 26, 2017 · 1 comment

Comments

@cstjean
Copy link
Contributor

cstjean commented Aug 26, 2017

On 0.6.0,

@generated function foo(x)
    return Nullable{Int}
end

function my_return_type(expr_type::Type)
    t = foo(expr_type)
    t <: Nullable
    return t
end

@btime my_return_type($Int)
  181.774 ns (0 allocations: 0 bytes)

Without the t<:Nullable line, it takes less than a nanosecond. It seems to me that the subtyping test should be computable at compile-time, since both of these functions are type-stable.

@yuyichao
Copy link
Contributor

Dup of JuliaCI/BenchmarkTools.jl#71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants