Using inherits is faster than is in general, I believe.
Using it in nf_preProcessMemberDataObj can give a surprisingly large (20%) speedup in a case where we are building many simple samplers. In code below buildMCMC takes 28 sec when using inherits and 36 sec when using is.
n <- 10000
code <- nimbleCode({
for(i in 1:n) {
y[i]~dpois(mu[i])
mu[i]~dnorm(mu0,sd=sigma)
}
mu0 ~ dnorm(0,sd=10)
sigma ~ dunif(0, 10)
})
m <- nimbleModel(code, data = list(y = rpois(n,1)), constants = list(n=n))
system.time(conf <- configureMCMC(m, useConjugacy=FALSE))
system.time(mcmc <- buildMCMC(conf))
Using
inherits
is faster thanis
in general, I believe.Using it in
nf_preProcessMemberDataObj
can give a surprisingly large (20%) speedup in a case where we are building many simple samplers. In code belowbuildMCMC
takes 28 sec when usinginherits
and 36 sec when usingis
.