Image source: Getty Images.

Think you've had a bad run as an investor? Try talking to someone holding shares of Twitter (TWTR): The company's stock has fallen 34% since it was revealed that all of the big names considering an acquisition have walked away.

While not as severe in the short term, those holding shares of Chinese search giant Baidu (BIDU 1.21%) haven't had much to cheer about, either. Since topping out in late 2015, the company has lost 30% of its value.

Given their poor recent performance, it's worth asking: Which is the better buy today?

Financial fortitude

I cannot underscore how underappreciated this is. Companies that have cash can afford to tinker and make mistakes while pursuing new opportunities. If times get tough, they can keep operations running, outspend their rivals into oblivion, and even make savvy acquisitions.

Companies that don't have cash -- and are in significant debt -- have zero options. They can't expand their operations, and if tough times hit, they will struggle to survive.

Here's how Twitter and Baidu fair on measures of financial fortitude:

Company 

Cash

Debt

Net Income

Free Cash Flow

Twitter

$3.6 billion

$1.6 billion

($409 million)

$295 million

Baidu

$15.7 billion

$0.5 billion

$4.98 billion

$2.58 billion

Data sources: Yahoo! Finance and SEC filings.

It's worth noting that Baidu is valued at over five times the size of Twitter. It's also worth stating that the reason Twitter's net income is negative is due to stock-based compensation. While that doesn't technically cost the company anything, it still dilutes shareholder value.

But even after taking all of this into consideration, it's clear that Baidu is in the superior position. Twitter's balance sheet isn't bad at all, but Baidu has over 10 times more cash than debt -- and it is continuing to generate billions in free cash flow. That fact alone makes it a stronger candidate.

Winner: Baidu

Sustainable competitive advantages

In my time investing, the most important variable in being able to predict the long-term success of any holding is the sustainable competitive advantage of the underlying company. In investing circles, this is referred to as a moat. Companies without a moat will eventually see competition come in and offer similar products at a lower price. That's great for consumers, but not so great for shareholders.

Both of these companies have powerful moats. Twitter CEO Jack Dorsey has rightly identified Twitter's key advantage as the fact that it is the de facto source of "live" everything: news, sports, weather, gossip...pretty much everything. No one can really challenge the company here.

It also benefits from the network effect, whereby with each new user, others have added incentive to join the network. The problem, however, is that this effect has stalled, which leads many to wonder why the service isn't catching on with everyday citizens the way that other social media sites have.

Baidu, on the other hand, benefits from being the runaway leader in search in China. According to China Internet Watch, Baidu captured 80% of all search market advertising revenue in 2015. While other players are trying to erode that lead, it's clear that Baidu is far and away the leader.

With Twitter having trouble making the network effect work in its favor, I'll give a narrow lead to Baidu here.

Winner: Baidu

Valuation

Finally, we have to determine how expensive each of these stocks are. While there's no perfect metric to do so, here are four of my favorite ratios to examine.

Company 

P/E

P/FCF

P/S

PEG

Twitter

31

40

4.7

1.8

Baidu

43

19

5.7

1.3

Data sources: Yahoo! Finance, SEC filings, and YCharts. P/E represents figure from non-GAAP earnings.

To be honest, these numbers are all over the place. Because of the investments that Baidu is making in its online-to-offline business, it looks very expensive on a price-to-earnings basis, but relatively cheap on a price-to-free-cash-flow basis. Generally, I tend to think the latter is a better snapshot at how expensive a company is.

At the same time, it's tough to measure Twitter's prospects. Since the company has struggled mightily to add subscribers, it's possible that there will be a significant headcount reduction in the quarters to come, which could boost profitability significantly.

All in all, I'll call this a tie.

Winner: Tie

Foolish bottom line

At the end of the day, Baidu is simply a stronger company than Twitter. Having been under the control of its founder, Robin Li, since its inception, it has nowhere near the identity crisis that Twitter is having. Baidu has a solid history of smart reinvestment, and I think it could pay off handsomely for shareholders in the years to come.