Costco Wholesale (COST -0.81%) and Walmart Inc. (WMT -0.24%) are two of the most dominant retailers in the world. In fact, no American brick-and-mortar retailers generate more revenue, and Walmart is the world's biggest company measured by revenue.

Though brick-and-mortar retailers have been threatened in recent years, Walmart and Costco have fared better than most, as their size arguably gives them competitive advantages over smaller retailers in addition to their economies of scale that allow them to keep prices low. As the chart below shows, both stocks have fared well over the last five years, especially recently.

WMT Chart

WMT data by YCharts.

Both Costco and Walmart have benefited from a surge in consumer spending, as retail sales have been especially strong this year, with nonautomotive retail sales up 6.3%. Against that backdrop, it's not surprising that both Costco and Walmart have been winners of late. Let's take a closer look at what each stock has to offer to see which is the better buy today.

A blurry image of a supermarket.

Image source: Getty Images.

The warehouse king

Costco offers a near-unique experience in retail, as the big-box retailer charms its customers with rock-bottom prices on a wide range of goods, some of which rotate in and out, providing a so-called "treasure hunt effect," all for the price of a $60 annual membership. Though there are other warehouse club chains such as Walmart's Sam's Club and BJ's Wholesale Club, Costco is by far the biggest and most successful in the sector, and recently the retailer has been on fire. 

For the fiscal year ended on Sept. 2, Costco posted comparable sales growth excluding fuel and foreign exchange of 7.4% in the U.S. and 6.8% globally, numbers that are significantly better than those of every other large retailer. E-commerce growth has also been solid, up 31.3%, as Costco's recent moves to offer free two-day delivery for nonperishables with a $75 minimum order and same-day delivery of perishables through Instacart appears to be paying off.

Earnings per share surged through the first three quarters of this year, up from an adjusted figure of $3.80 last year to $4.74, representing 25% growth. Costco also continues to open new stores, unlike Walmart and many other retailers, indicating its continuing faith in traditional retail; it added 21 warehouses over the past year to reach a total of 762. That strategy has been rewarded with strong growth, and Costco continues to have sales per square foot significantly above those of other big-box chains at $1,120 over the last four quarters. Finally, its membership model also gives it an advantage, as it derives the majority of its profits from membership fees, not merchandise sales. With renewal rates continuing to be around 90%, that revenue stream looks safe.

An awakening giant

Like Costco, Walmart has also been on a roll lately. Comparable sales at its U.S. stores jumped 4.5% in its most recent quarter, its fastest pace in more than 10 years, as the company's investments in initiatives like grocery pickup stations, cleaner stores, and better employee training as well as acquisitions like Jet.com are paying off. U.S. e-commerce sales were up 40%, assuaging concerns about slowing growth earlier in the year, and its Sam's Club and international divisions are also executing. Comparable sales at Sam's Club, its warehouse chain and Costco competitor, rose 5% in the second quarter, and comparable sales were positive in its four largest international markets, driving currency-neutral revenue growth of 3.1%.  

While Walmart's top-line growth has been impressive, the investments it has made to keep up with competitors like Amazon have compressed margins, as currency-neutral operating income fell 5% to $5.7 billion in the quarter. 

Still, the retail giant is clearly on the right track, as the company raised its adjusted earnings-per-share guidance to $4.90 to $5.05 from $4.75 to $5.00, and for comparable sales of 3% at Walmart U.S. stores, up from a previous forecast of at least 2%. Walmart has also been making smart moves to rearrange its international portfolio, selling off a majority of Walmart Brazil stock, combining its U.K.–based Asda subsidiary with Sainsbury's, and taking a majority stake in Flipkart, the leading e-commerce retailer in India, which is expected to eventually be the world's biggest e-commerce market.

The fundamentals 

Looking at the hard numbers on valuation and dividend yield here, Walmart is the winner, as its stock trades at a P/E of 20 compared to Costco's at 33.7. For income investors, Walmart also looks like the better bet, as it offers a dividend yield of 2.2% versus Costco's at 1%. But Costco's dividend yield is effectively higher, as the company has a history of making special dividend payments that are significantly higher than its regular quarterly payouts. 

However, a look at these companies' recent same-store sales and earnings growth shows why Costco shares warrant a higher valuation. As the chart below shows, Costco's comparable sales growth has consistently outperformed Walmart's. 

A line graph

Walmart and Costco comparable sales. Data Source: Walmart and Costco 10-K filings.

As you can see from the chart, even Costco's worst same-store sales growth over the last six years is still better than Walmart's best. Similarly, Costco has grown its earnings per share by more than 50% during that time, while Walmart's EPS has remained virtually flat.

I think both of these stocks are good candidates to outperform the broader market, and I've given both a thumbs-up in Motley Fool CAPS. Between the two of them, Costco looks like the better choice. With its membership model, it is better insulated from threats such as Amazon, and the company has consistently outperformed Walmart and its other brick-and-mortar rivals. Even with the higher price tag, I'd rather own Costco.