Wind back the clock about four years. In 2002, the refining business was in the dumps. Margins were low, and smaller companies like Giant Industries (NYSE:GI) and Tesoro (NYSE:TSO) were burdened with debt. Many thought they would go under. Their stocks sank into the single digits, and their market caps put them firmly into the microcap category.

New day rising
The investing world changes quickly. Today's ugly duckling may be tomorrow's 10-bagger. As an example, Giant Industries reported second-quarter earnings of $3.37 per share, up 120% over the already strong results in 2005. The stock now trades in the neighborhood of $70. Investors who had enough courage to wade into these waters at the darkest hour are sitting on a 20-bagger.

This quarter's rise in earnings was driven by a whopping crack spread (an industry measure of profitability based on the difference between crude prices to finished product prices) of $21.97/bbl (barrel) for Giant's New Mexico refineries, a 63% gain over 2005. To show just how great these margins are, during the dark days of 2002, refiners were ecstatic with a crack spread of $4/bbl.

Aside from the strong financial performance, operational performance had a few bumps. Refinery throughput was lower at Giant's Yorktown, Va. refinery due to a fire last November. The Bloomfield, N.M., refinery ran at lower rates due to scheduled maintenance. The fire highlights one of the risks in a small refining company: Each plant has a huge impact on results. Had the crack spread been flat or declining, Giant would have likely posted an earnings decline.

Still a value?
After the huge gain of the past four years, it's a fair question whether or not investors should be cashing out. After all, fellow companies from the oil patch, like Frontier Oil (NYSE:FTO), are starting to show up on lists of the market's 10 best stocks. While we can only speculate about the future of crack spreads and how long the current cycle will last, we can compare Giant to its peers. In sifting through the numbers, I started comparing enterprise value (market capitalization plus net debt) to refining capacity in bpd (barrels per day). Looking at pure refining companies shows the following:

Company

Enterprise Value

Refining Capacity

EV/Capacity

Giant

$1.19 Billion

104,000 bpd

$11,442

Tesoro

$5.67 Billion

560,000 bpd

$10,125

Alon USA (NYSE:ALJ)*

$1.65 Billion

160,000 bpd

$10,312

Valero (NYSE:VLO)

$45.92 Billion

3,300,000 bpd

$13,915

* Estimated after completion of Paramount and Edgington acquisitions

Last year, Valero purchased Premcor for roughly $10,000 per bpd. It appears as though all of the refiners have risen to this valuation. Furthermore, based on this metric alone, Valero may be a bit overvalued.

In conclusion...
I think it would be too optimistic to suggest that growth can continue from ever-increasing crack spreads. However, the U.S. needs additional refining capacity. From an investing standpoint, I prefer the small refiners, because they can make large percentage gains in capacity with smaller acquisitions and projects that would be meaningless to the likes of Valero.

Therefore, I am watching whether or not the refiners can add meaningful volumes of capacity for less than $10,000/bbl. For the large refiners, this isn't so easy. Marathon Oil (NYSE:MRO) is spending more than $12,000/bbl for the 180,000 bpd expansion of their Garyville, La. refinery. If you want to build from the ground up, Arizona Clean Fuels Yuma estimates the cost of their proposed new refinery to be $16,700/bbl. So while Giant is unlikely to deliver another 20-bagger, it can certainly deliver solid returns if management increases capacity for a reasonable price.

Giant Industries isn't a Motley Fool Hidden Gems recommendation, but the team has uncovered some compelling values in the oil patch. To see all current Hidden Gems recommendations, which are beating the marketclick hereto sign up for afree trial. Valero is a former Hidden Gems pick.

Fool contributor Robert Aronen owns shares of Alon USA, but no other company mentioned. He welcomes your comments. The Fool has an ironclad disclosure policy.