Spectral estimation for Hamiltonians: a comparison between classical imaginary-time evolution and quantum real-time evolution