For the most part, grocery companies are both slow growing and boring. But then there's Costco (COST -0.24%) and Whole Foods (WFM) -- two clear leaders in their respective niches and both continually challenging norms accepted by competitors. However, no matter how "hot" these companies might be, is the value in their stock price compelling? To aid in an analysis of these stocks' investment prospects, here's a head-to-head comparison of the two companies:

Metric

Costco

Whole Foods Market

Trailing-12-Month Revenue Growth (YOY)

1.4%

6.3%

Trailing-12-Month EPS Growth (YOY)

2%

(7%)

5-Year EPS CAGR

12.9%

15.7%

P/E

28.7

21

Costco
The greatest facet of Costco as an investment is the company's durability. Over the years, Costco has grown in size and flexed its industry-leading scale as a competitive advantage. Known for its operational efficiency and its astute execution, Costco is consistently able to deliver leading value for its wholesale members while simultaneously growing profits for shareholders despite its competitive merchandise pricing.

This discipline in operational efficiency and capital allocation, paired with the company's scale advantage, has helped drive outsized growth in earnings per share compared to revenue growth over the past five years.

COST Normalized Diluted EPS (TTM) Chart

COST Normalized Diluted EPS (TTM) data by YCharts.

Costco's EPS has increased an average of about 13% annually over the last five years on approximately 8% annual revenue growth. But investors will have to pay a steep premium to buy this excellent business. Costco trades at nearly 29 times earnings.

Whole Foods
When it comes to stores that offer only natural and organic food, Whole Foods is the market leader by a long shot. Indeed, Whole Foods' lead on other organic grocery stores is so significant that it could be compared to Costco's dominance of Wal-Mart's Sam's Club. In other words, there is no clear second to Whole Foods' dominance in the organic grocer space today.

Image source: Whole Foods.

Unlike Costco, however, Whole Foods has faced challenges growing its EPS in line with revenue. Heightened competition as Kroger and Costco ramp up their organic and natural offerings has pressured the company's premium prices. As competition continues to heat up, investors are concerned the company won't be able to sustain its impressive 3.4% net margin. And investors are probably right; this net margin will almost certainly come down.

But worries about competition have helped create a buying opportunity. The stock is down 36% during the past twelve months and the stock's price-to-earnings ratio of 21 is fairly low when viewed next to the company's growth and its long-term prospects. Over the long haul, the company's comparatively faster revenue growth than Costco's should help Whole Foods return to EPS growth -- even if its net margin is pressured.

If management is right about Whole Foods' growth potential, there's significant runway ahead. Whole Foods currently has just over 400 stores. But management believes there's potential to nearly triple this store count -- and this doesn't even include its new 365-branded store format, which the company had already signed five leases for when it reported first-quarter results earlier this year.

Investors who buy amid these challenging times for Whole Foods -- and before it returns to its historical precedent of prudent capital allocation and EPS growth -- could see market-beating returns.

In light of its more conservative valuation, I think Whole Foods stock is a better buy than Costco.