Part of what makes Costco (COST -0.44%) such a strong investment is that its membership model is well protected from e-commerce threats. Customer traffic at its warehouses improved at a market-thumping 4% annual pace for the past six years, even as online sales soaked up a growing share of the overall retailing pie. In other words, Costco has demonstrated that, in some important ways, it is (AMZN -0.29%) proof.

That success hasn't bought shareholders stellar returns, though. Costco's stock has barely kept pace with the market over the last one-year and five-year time frames while Amazon's has significantly outperformed.

AMZN Chart

AMZN data by YCharts.

Which one is the better buy for investors right now? Both are dominant leaders with the right focus on prioritizing customers over short-term profits. For my money, though, Costco is a better deal given its cheaper valuation and more predictable stream of earnings.

Business trends favor Amazon

Costco's awesome retailing growth pace (of 6% or better comparable-store sales in each of the last five years) is ending. In fact, the retailer's comps were just 4% over the full fiscal year that ended in August. That number is likely to continue dropping, too, since the broader grocery industry, wracked by deflation, is going through its worst growth patch since 2009.

Amazon, in contrast, has the wind firmly at its back. Sales spiked by 31% last quarter, and operating cash, a key financial metric for CEO Jeff Bezos and his team, has jumped by 42% in the last year.

Earnings are an even bigger story for shareholders lately. Amazon is not only profitable again, but its bottom-line margin is set to pass Costco's for the first time since late 2011.

AMZN Profit Margin (TTM) Chart

AMZN Profit Margin (TTM) data by YCharts.

Judged solely by their latest operating trends, Amazon is the better bet right now.

Costco has steadier earnings

On the other hand, a Costco investment provides the type of steady, predictable growth that's rare in the retailing world and even harder to find in the tech circles where Amazon is competing. Since most of Costco's earnings are produced through membership fees rather than product sales, shareholders can count on the company growing returns even in tough selling environments like this. Profits should actually speed up given that a membership-fee hike is likely either this year or next.

Costco annual earnings. Data source: Financial filings.

Amazon's profit pace is much harder to predict -- it generated a loss in two of the last five fiscal years. A large portion of future earnings will come from its cloud-based AWS business services, too. And while that's an attractive growth industry, it requires tons of capital investment in a competitive environment marked by falling prices. Lately, revenue has been rising at a fast-enough pace to outweigh those negatives, but that trend could quickly shift.

Amazon is far more expensive

Mr. Market is offering investors Amazon stock at 73 times the $10.40 per share of earnings it's expected to produce next year. Costco, meanwhile can be had for 25 times its projected $6 per share of profit. A similarly large gap holds when you compare the stocks on a price-to-sales basis. Amazon is valued at three times trailing revenue compared to 0.6 times for Costco.

Amazon clearly deserves a premium given that its sales and profits are growing at a much faster pace. The e-commerce giant is also poised to pass Costco in overall revenue, net income, and net profit margin, which are impressive achievements.

Investors have to pay up for the broad optimism around this business, though. In contrast, worries over a temporary sales-growth slowdown have kept Costco's stock more reasonably priced -- and that lowers the risk of buying into shares just as inflated expectations come back down to normal.