Let's rewind a decade. In mid-August 2007, you could have bought shares of a fledgling Chinese search engine named Baidu (BIDU 1.25%) for just $17.50. At the same time, an online bookstore that was just starting to gain traction as an "Everything Store" in e-commerce named Amazon.com (AMZN 2.80%) was trading for a paltry $75 per share.

Since then, their returns have been the rarest of beasts: 10-baggers. In other words, $10,000 invested in either one is now worth over $100,000.

AMZN Chart

AMZN data by YCharts.

While those who have owned shares throughout that ride can pat themselves on the back, it doesn't do much for today's investors. The stock market is a forward-looking entity. Given that, it's worth asking: Which stock is the better buy today?

That's impossible to answer with 100% certainty, but we can get a better idea of what we're paying for by evaluating both companies on three different metrics.

Sustainable competitive advantage

If you want to explain to someone how a company can grow and remain dominant for so long, look no further than its sustainable competitive advantage -- or moat. While some companies can ride a wave of sales momentum to nosebleed valuations, only those with wide moats can actually survive and be decades-long successful investments.

In its simplest sense, a moat is what keeps customers coming back for more, year after year, while the competition flounders.

Baidu's moat is provided by its market share and brand. The company is the leading search engine in China, according to StatCounter -- with a 75% share of the overall search market in the Middle Kingdom and an 82% share of the mobile market, which is where most new internet users come from in China.

By becoming the default search engine in China, Baidu is able to compile data that others can't compete with and offer that data up to advertisers. While the company suffered a hiccup in the loss of certain advertisers over the last year, it looks like it is moving beyond those concerns. And while efforts around artificial intelligence and online-to-offline (O2O) infrastructure are promising moat builders, it's still too early to tell how wide they will be.

Normally, this would be more than enough to declare a winner. But in Amazon, we have one of the widest-moat businesses in the world.

A woman looking at a wall with two arrows pointing in two opposite directions.

Which one will you choose? Image source: Getty Images.

We'll start with scale: Amazon has 105 fulfillment centers domestically and another 111 abroad. These multimillion-dollar warehouses guarantee shipping that's quicker than just about anyone else can offer. And the competition would have to run in the red for years just to catch up.

Then we have high switching costs. If you can find a deal to get as much from a membership as you do with Amazon Prime -- including free two-day shipping, access to a library of original TV and movie content, and a host of other benefits -- then you've hit the jackpot. For most people, the costs of switching away from Prime are just too high.

And finally, we have the network effect. As more and more people flock to Amazon, third-party retailers have the incentive to list their products on the site and use the Fulfillment by Amazon (FBA) service. That draws, even more, people to Amazon, creating a virtuous cycle. Last year, the number of people using FBA jumped 70%, with the number of packages shipped during the holidays through FBA growing by 50%. 

The combination of those factors, in my opinion, gives Amazon the edge.

Winner = Amazon 

Financial fortitude

Neither one of these companies offers up dividends, and they both are (in)famous for plowing sales right back into growth initiatives. For long-term investors, that's more than worth the risk, as the pace of change in the world only accelerates; companies that don't reinvest will simply be left behind.

But there's something to be said for boring old cash. That's because tough times will once again befall -- either on a macro or company-specific level. And when those times come, outfits with cash will only get stronger: by buying up their own shares, acquiring rivals, or simply spending the competition into bankruptcy.

Those that are debt-heavy are in the opposite camp, fragilized by their leverage. Keeping in mind that Amazon is valued at six times the size of Baidu, here's how they stack up.

Company

Cash

Debt

Net Income

Free Cash Flow

Baidu

$20 billion

$5 billion

$2 billion

$3 billion

Amazon

$22 billion

$8 billion

$2 billion

$9 billion

Data source: Securities and Exchange Commission filings, Yahoo! Finance. Net income and free cash flow presented on a trailing-12-month basis. Figures rounded to nearest billion.

On an apples-to-apples comparison after taking size into consideration, we could argue that Baidu has the healthier balance sheet. But that's not necessarily what I'm looking for here.

Both companies have healthy amounts of cash consistently flowing into their pockets, more-than-manageable levels of debt, and significant war chests they can rely on.

Winner = Tie

Valuation

And then we have the can of worms that is valuation. There isn't one metric that can tell you just how expensive a stock is. Instead, I like to use a number of data points to get a more holistic picture.

Company

P/E

P/FCF

PEG Ratio

Baidu

33

28

1.6

Amazon

250

53

9.1

Data source: SEC filings, Yahoo! Finance, E*Trade. P/E represents non-GAAP earnings.

This is a pretty easy one to call. On virtually every possible metric, Baidu is considered cheaper than Amazon. A huge part of that is Amazon CEO Jeff Bezos' insistence that the company continually invest for the future to maximize the long-term potential free cash flows.

When that "long-term" will come to fruition is anybody's guess, but it means that Baidu has the more favorable valuation at today's prices.

Winner = Baidu

My winner is...

So there you have it: Both companies have solid balance sheets, Baidu is cheaper, but Amazon has the stronger moat. In the case of ties, I always side with the company that has the wider moat. In this case, that means Amazon comes out ahead.