I was surprised when I first heard that the energy produced at the Sun's core takes a long time to escape the Sun. The process is often explained as a photon traveling a "drunkard's walk" based on the mean free path within the layers of the Sun.
One such NASA estimate is linked here. It mentions estimates ranging from 4,000 years to several million years.
It occurred to me that maybe the diffusion time could better be estimated by dividing the total thermal energy of the Sun by the power output of the Sun. One estimate of the thermal energy of the Sun is 3.09 x 10^41 J given in the accepted answer of this question. On Wikipedia, I found that the Sun's luminosity is 3.828 x 10^26 W.
Dividing, we get a time of 8.07 x 10^14 seconds, or about 26 million years. I guess this is how long it would take the Sun to cool completely if it stopped producing energy, but kept radiating at its current rate.
Does my calculation make sense? 26 million years is above the usual estimates of energy diffusion times.
EDIT BELOW:
I want to explain why I thought that the simple division of thermal energy by luminosity would give a reasonable estimate of the energy diffusion time.
Assume that each bit of energy produced in the Sun's core travels radially outward at a steady pace until reaching the surface. I think it's clear that, given the inputs above, each bit of energy would require 26 million years to escape.
Now, due to the "random walk" nature of the diffusion process, each bit of energy will take a random amount of time to escape. My thinking is that the average escape time would still have to be 26 million years to maintain the Sun's (fairly constant) thermal energy and luminosity.