# Benchmark specialized method against general method

**URL:** <https://discourse.julialang.org/t/benchmark-specialized-method-against-general-method/8978>\
**Category:** General Usage\
**Created:** [February 10, 2018, 4:36pm UTC](https://discourse.julialang.org/t/benchmark-specialized-method-against-general-method/8978 "2018-02-10T16:36:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)\
**Post date:** [February 10, 2018, 4:36pm UTC](https://discourse.julialang.org/t/benchmark-specialized-method-against-general-method/8978/1 "2018-02-10T16:36:55Z")

</div>

Julia always uses the most specialized method. For a specific occasion, is there a way to force it to instead use the method that is one level more general? Or, more generally, _any_ specific more general method?

For example, with the following definition,

```
julia> f(x) = x
julia> f(x::Int) = 2*x

```

I’d still like to be able to do something like `f(Any(2))`, and have `2` returned. In _some_ cases, I am able to use type conversions to get to the more general method, but there is no concrete `Any` type, so that doesn’t work generally.

The purpose of this is profiling: I’d like to profile a new more specialized method against the older, slightly more general method. Preferably without copying the code for the older general method to a new name.

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [February 10, 2018, 4:45pm UTC](https://discourse.julialang.org/t/benchmark-specialized-method-against-general-method/8978/2 "2018-02-10T16:45:36Z")

</div>

```julia
julia> invoke(f,Tuple{Any},2)
2

```
