Costco (COST 0.17%) and Home Depot (HD -1.77%) stocks are on fire lately -- they've each soundly outperformed the S&P 500's 76% return over the last five years.

COST Chart

COST data by YCharts.

Costco's bounce has a lot to do with a six-year streak of customer traffic gains that's stuffing its aisles with shoppers. The warehouse retailer's U.S. membership base has jumped to 42 million from 31 million in 2009. Those subscribers are shopping more frequently and spending more per visit than they ever have.

Meanwhile, a steadily improving housing market has had the same traffic-juicing effect on Home Depot's business (transaction volume is 3.5% through the last two quarters). Investors have at the same time benefited from a massive profitability expansion: Operating margin has more than doubled from the 6% trough it hit in 2009 to reach a fresh all-time high.

So which of these ultra high-performing big-box stores makes the better investment today? Here are a few comparison points to get us started:

MetricHome DepotCostco
Market cap $147 billion $61 billion
Net sales $83.2 billion $110 billion
Dividend yield 2% 1.1%
Sales growth 5.3% 6%
Profit margin 13% 3%
Price/earnings 22x 27x
Price/sales 1.8x 0.6x

Sales, profit margin, and sales growth are for last fiscal year. P/E and P/S ratio cover the trailing 12 months. Sources:  S&P Capital IQ data and company financial filings.

Buy Home Depot for profit growth
Home Depot's operations are chugging along at record levels, but it's what management is doing with those gains that makes this stock such an attractive investment right now. As mentioned above, profitability is at a new high, having leapt from 6% to 13% in the last five years. Return on invested capital, at 25%, is also more than twice what it was in 2010. And other key efficiency metrics are all pointing in the same direction. To name just two more examples, working capital is down and inventory turnover has improved by 20% in the last five years.

COST Operating Margin (TTM) Chart

COST Operating Margin (TTM) data by YCharts.

But probably the single best efficiency metric to watch is cash flow. Operating cash is at an $8 billion annual pace, up 20% in just the last two years. CEO Craig Menear and his executive team have made it clear that they want to send all of the excess cash to investors. The company returned $9.5 billion to shareholders in 2014 through share repurchase and dividends.

Buy Costco for the predictability
Costco's business doesn't have nearly same level of profitability as Home Depot's. But don't let its tiny 3% operating margin scare you off of this potential investment. 

After all, membership subscriptions, not product sales, are Costco's main business. And that business is booming: Total paying cardholders rose by 500,000 last quarter to reach 43.7 million.

U.S. renewal rate by fiscal year. Source: Costco financial filings.

Those members now kick in fee revenue that was up 7% year over year to $1.7 billion, or roughly three-quarters of the warehouser's entire operating profit. The best news for investors about that growing subscriber fee pool is that it is so predictable. Thanks to a record-high 91% renewal rate, shareholders can count on a huge chunk of Costco's earnings streaming in like clockwork, whether the economy stays flat, dips, or surges in the years ahead.

Foolish bottom line
The biggest risk when buying a high-performing company like Costco or Home Depot is paying too much. Indeed, at over 20 times last year's earnings, both stocks are valued at a significant premium to the market.

Still, on that basis, Home Depot and Costco are cheaper than they've been all year, so now could be a good time to start a position if you've been waiting on the sidelines. Income investors might prefer Home Depot thanks to its hefty 2% dividend yield and fast-growing payout. But if you're after profits you can rely on through major market swings, then Costco is your better bet.