For years, Wal-Mart (WMT -1.75%) and Costco Wholesale (COST 1.01%) have been the two leading American retailers, posting more revenue than any of their rivals. That streak looks set to end this year as Amazon.com passes Costco, but nonetheless, the two companies reign supreme in the brick-and-mortar world.

The companies have a great deal in common. They both rose to prominence thanks to their low-price leadership. Wal-Mart has done this through its everyday low prices strategy, while Costco's bare-bones warehouses help it deliver rock-bottom prices on bulk goods. Wal-Mart even has its own Costco-like chain, Sam's Club, which generates about 12% of the company's total revenue. Both Wal-Mart and Costco have an international presence, but still make the bulk of their revenue and profits from the U.S.

Still, there are important differences between the two. Costco tends to cater to a more upscale customer than Wal-Mart due to its $55 annual membership fee, while Wal-Mart attracts a lower and middle-income clientele. Because of that, Costco's stores are generally found in and around major cities, and about one third of its locations in the U.S. are in California. Wal-Mart, on the other hand, is most common in the South, and tends to favor rural locations. The company likes to point out that 70% of Americans live within five miles of a Wal-Mart store.

Today, as part of our better-buy series, we'll take an in-depth look at each company to determine which is the better stock for investors today.

Image Source: Wal-Mart.

Trouble in Wally World

While Wal-Mart is far and away the global retail leader and has more revenue than any other company in the world, the superstore chain finds itself threatened today like never before.  For the first time in at least 45 years, Wal-Mart reported a decline in revenue last year. Competition from Amazon and e-commerce has upset the traditional retail model, forcing Wal-Mart to rethink the way it does business.

New CEO Doug McMillon has made some uncharacteristic moves, including raising base wages to $10/hour and making investments to clean up stores, bring back greeters, and ensure that products are in stock. The company has also stepped up investment in its e-commerce platform, and has scaled back on opening new stores. It's rapidly expanded its grocery pick-up service, which allows customers to order online and pick up perishables and other foodstuffs from a parking lot kiosk, and just spent $3.3 billion on e-commerce upstart Jet.com, a bet on that company's pricing technology and the brains of its founder Marc Lore, who sold his previous company, Quidsi, to Amazon.

2016 is a transitional year for the retail giant, but there are signs that McMillon's strategy is paying off. Same-store sales at U.S. stores grew by 1.6% in its most recent quarter, the fastest clip in several years, and e-commerce growth accelerated for the first time in two years. Last October, management outlined its turnaround plan, promising that this year would be its biggest investment year with EPS falling 6% to 12%, but that EPS would grow 5-10% in fiscal 2019 (calendar year 2018). Though it's still early in the transition, Wal-Mart appears to be on track to return to profitable growth.

Image Source: Motley Fool. 

Costco's also feeling the heat

Though Costco stock has outperformed Wal-Mart's in recent years, the warehouse retailer finds itself in a similar predicament as the rise of e-commerce threatens to take customers away from the warehouse giant. Costco has an e-commerce presence, but management has been reluctant to embrace the platform as it would rather drive traffic to its cavernous stores, where customers can make impulse purchases and buy bulk goods that are difficult to ship.  

Earnings per share have actually fallen through the first three quarters of the year due to lower gas prices and foreign currency exchange, and the company's underlying comparable sales growth has also slowed. Last quarter it was 3% in the U.S. and globally, and its fourth quarter is on a similar pace based on the company's monthly reports. That clip may be decent for most retailers in today's environment, but Costco's comparable sales had been increasing in the mid-to-high single digits for several years, and the recent results could be a sign of a longer-term, secular slowdown.

Membership fees, the source of most of the company's profits, have continued to increase at a modest pace, up 5.8% in the most recent quarter and 3.8% for the year thus far, though those figures don't account for currency fluctuations. At a P/E of 31, Costco's valuation is also double that of Wal-Mart's, indicating higher expectations from investors. 

And the better buy is...

Investors' preference between Costco and Wal-Mart may come down to investing style. Value investors and dividend hunters are likely to prefer Wal-Mart, which trades at half the valuation of Costco and offers a dividend yield of 2.8% compared to just 1.1% for Costco.

Growth-minded investors, on the other hand, may prefer the warehouse retailer, which despite its recent headwinds is still delivering respectable comparable sales growth and has a membership renewal rate of around 90%, indicating high customer satisfaction. As gas prices and currency even out, profit growth should return for Costco. 

Both companies appear to be challenged by the rise of e-commerce, but, on balance, I'd say the better buy of the two is Costco. Its membership base provides a consistent source of profits, and the company has a long track record of growth. Though its high P/E ratio could leave room for multiple compression if profit growth slows, I'd still expect it to outperform Wal-Mart over the coming years.