|MadSci Network: Astronomy|
The Sun would only last about 20--30 million years if gravitational collapse were its only source of energy. Once upon a time, the sun did receive its energy this way - this was during its formation, when it shrank from about 2-3 times its current size to the size it has now. At the end of this contraction, the temperatures in the core of the sun became sufficiently high that hydrogen began fusing into helium, providing an energy source that lasts far longer than gravitational contraction. The Sun would only need to shrink by 1-2 kilometers per year to provide its luminosity from gravitational contraction.
Try the links in the MadSci Library for more information on Astronomy.