When it comes to retail, everyone is focused on what Amazon.com is doing and which industry will get disrupted next. That makes it easy to forget the fact that e-commerce still accounts for less than 10% of all retail purchases in the United States.

What accounts for the other 90%? Tons of retailers. But two of the biggest have the stocks that will be going head-to-head in today's competition: Costco (COST -0.24%) and Walmart (WMT 0.46%). Over the last five years, the membership-based model of Costco has helped the company's stock double the returns of Walmart.

Abstract blur of a supermarket aisle

Image source: Getty Images.

Will Costco's outperformance continue? It's impossible to tell with certainty. But by examining the companies through three distinct lenses, we can get a better idea of which is the better buy at today's prices.

Sustainable competitive advantage

In the investing world, there's nothing more important to evaluate than the sustainable competitive advantages of companies that you want to own. These advantages are often referred to as a company's "moat."

In the simplest sense, a moat is the special something that keeps customers coming back for more -- year after year -- while holding the competition at bay for decades.

Both Walmart and Costco benefit from a crucial advantage of economies of scale: By having such a huge number of shoppers globally, with locations spread across North America and the globe, each company can bargain for lower prices from third-party vendors that it can then pass along to consumers.

But because both companies benefit from this, it's not much of a differentiator.

Costco also benefits from moderately high switching costs. Put simply, it's tough to find a better deal on food and "stuff" than what you can find at Costco. Membership fees -- which run $60 per year for a basic card -- made up 106% of the company's profit. In other words, the core business -- minus the membership fees -- ran at a loss last year, and it always has.

That's a tough business model to beat. Under normal circumstances, I would argue that this gives Costco the edge. But recently, Walmart has been able to leverage its physical locations in North America impressively in upping its e-commerce game. Sales from the channel -- catalyzed by the acquisition of Jet.com -- have given Walmart another avenue for growth. While it seems like that growth may be stalling right now, the sheer number of the company's physical locations give it an advantage in terms of expanding e-commerce presence and ease of delivery.

Winner = Tie.

Financial fortitude

Next, we have financial fortitude. While most investors in behemoths like Walmart and Costco would like to see excess cash returned to them via share buybacks or dividend payments, there's something to be said for keeping a boring pile of cash on hand.

That's because every company, at one point or another, is going to face difficult economic times. Those that have cash on hand can actually get stronger because of it -- by buying back shares on the cheap, acquiring disruptive upstarts, or bleeding the competition dry by undercutting prices to gain long-term market share.

Keeping in mind that Walmart is valued at almost four times Costco, here's how the two stack up.

Company

Cash

Debt

Free Cash Flow

Costco

$6 billion

$7 billion

$4.2 billion

Walmart

$7 billion

$37 billion

$18.3 billion

Data source: Yahoo! Finance. Cash represents cash and short- and long-term investments. Free cash flow presented on a trailing-12-month basis.

Relative to their sizes, both companies have comparable free cash flows. But when it comes to the balance sheet, Costco is in a position to benefit more in the case of an economic downturn than Walmart. As such, Costco gets the nod here.

Winner = Costco.

Valuation

Finally, we have valuation. Unfortunately, there's no one metric that will tell us if a company's stock is cheap or expensive. Instead, I find it best to consult a number of data points in building out a holistic picture.

Company

P/E

P/FCF

PEG Ratio

Dividend

FCF Payout

Costco

31

20

2.5

1.1%

19%

Walmart

21

15

2.8

2.2%

33%

Data sources: Yahoo! Finance, E*Trade, Nasdaq.com. P/E = price to earnings, P/FCF = price to free cash flow, PEG = price/earnings to growth; FCF = free cash flow. Dividend and payout for Costco do not include the effect of a recent one-time, special dividend.

Both companies have relatively small dividends that are very sustainable and have lots of room for growth. But in terms of earning and free cash flow ratios, Walmart is clearly the cheaper of the two choices.

Winner = Walmart.

My winner is...

So based on these three criteria, we have a tie. Usually, when this is the case, I side with the company with the wider moat. Here again, however, we are stuck: Neither company is an upstart disrupter anymore. And given that their moats are equally wide, I believe that valuation should play an outsized role. Walmart is fairly valued in my opinion, while Costco seems a touch expensive.

My vote goes to Walmart.