Why not just append `thread.sleep(random() % 1000)' to your calculations if you are worried about timing attacks?
Then we calculate the sample mean of this distribution, X. Keep in mind that I can then set the number of samples to take to achieve my desired accuracy and confidence.
Then we look at the mean of the distribution x + R?
E(x + R) = E(x) + E(R) = x + E(R) = x + 500
So therefore the true running time is recoverable by taking X - 500.Also, when a thread is sleeping, the OS will schedule other threads, which opens many additional ways for attackers to notice that sleeping started.
I've written about this before on this site: https://news.ycombinator.com/item?id=16069502