# How to recompile specific methods

**URL:** https://discourse.julialang.org/t/how-to-recompile-specific-methods/62340
**Category:** New to Julia
**Created:** [June 3, 2021, 3:16pm UTC](https://discourse.julialang.org/t/how-to-recompile-specific-methods/62340 "2021-06-03T15:16:54Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![kimikage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimikage/32/14534_2.png) [@kimikage](https://discourse.julialang.org/u/kimikage)
#### Post date: [June 4, 2021, 12:29am UTC](https://discourse.julialang.org/t/how-to-recompile-specific-methods/62340/7 "2021-06-04T00:29:10Z")

</div>

Here is an example.

```julia
julia> using Colors, BenchmarkTools

julia> rgb_f64 = rand(RGB{Float64}, 1000);

julia> @btime convert.(XYZ{Float64}, $rgb_f64);
  130.900 μs (5760 allocations: 113.48 KiB)

julia> precompile(Tuple{typeof(convert), Type{XYZ{Float64}}, RGB{Float64}}) # for example
true

julia> @btime convert.(XYZ{Float64}, $rgb_f64);
  130.900 μs (5760 allocations: 113.48 KiB)

julia> @noinline Colors.pow12_5(x::Float64) = x^2 * exp(0.4 * log(x)) # force invalidation (the body is not changed)

julia> @btime convert.(XYZ{Float64}, $rgb_f64);
  50.700 μs (2 allocations: 23.52 KiB)

julia> versioninfo()
Julia Version 1.7.0-DEV.1133
Commit db8d09609c (2021-05-21 13:48 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)

```

For the root causes, the following would be appropriate places for discussion, not here.  
[https://github.com/JuliaLang/julia/issues/35972](https://github.com/JuliaLang/julia/issues/35972)  
[https://github.com/JuliaLang/julia/issues/34055](https://github.com/JuliaLang/julia/issues/34055)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-recompile-specific-methods/62340)._
