carstenbauer / MonteCarlo.jl

Classical and quantum Monte Carlo simulations in Julia
https://carstenbauer.github.io/MonteCarlo.jl/dev/
Other
185 stars 18 forks source link

cache `acosh(exp(0.5 * m.U * dtau))` #140

Closed ffreyer closed 2 years ago

ffreyer commented 2 years ago

Calculating this only takes about 9ns, but since it's calculated in propose_local! it's called very frequently. Throwing this in a RefValue{Float64} in model (Ref{Float64} is abstract) may actually reduce the total runtime by a few percent.

ffreyer commented 2 years ago

Did some quick and dirty benchmarking:

  1. With BenchmarkTools propose_local goes down from 52ns to 18ns mean time
  2. With TimerOutputs it's 187ns -> 141ns

But the simulation spent <1% in propose_local, so there isn't really a point in optimizing it further.