It hasn't always been smooth sailing for Baidu (NASDAQ:BIDU) and MercadoLibre (NASDAQ:MELI), but both stocks have delivered market-beating gains for shareholders since their IPOs over 10 years ago.

Even though Baidu continues to post impressive growth rates on the top and bottom lines, the stock is only up 27% over the last five years as investors ponder the potential consequences of government regulation in China and competition from other Chinese tech giants. Meanwhile, MercadoLibre shares are up 134% over the last five years, as its marketplace continues to ride the wave of e-commerce growth in Latin America. 

But past performance is not always the best indicator of future performance. With that in mind, let's compare both companies to see which is the better buy today.

A plant growing out of a pile of coins.

Image source: Getty Images.

What you need to know about Baidu

Baidu is the largest search engine in China. It's been described as the "Google of China" because it mirrors Alphabet's Google in several ways: It derives most of its revenue from advertising, and it's investing in other moon-shot opportunities like self-driving cars and artificial intelligence (AI).

The Chinese search giant recently spun off its online video service iQiyi, in which Baidu continues to remain a controlling shareholder. Revenue from iQiyi made up a quarter of total revenue in 2017. It's growing much faster than Baidu's advertising business, clocking a growth rate of 43% in the last quarter. Baidu has been investing aggressively to secure content for the service. 

Although online marketing services made up 82% of Baidu's revenue in the last quarter, the company is getting recognized more for its efforts in businesses that are not ad-related. There's huge growth potential in its Apollo self-driving car program, which recently produced two level 4 autonomous vehicles and has partnerships with Intel's Mobileye automotive unit, as well as top carmakers. 

Baidu is also getting attention for its investments in its PaddlePaddle deep learning platform and its DuerOS operating system for smart-home devices. 

The main risk for Baidu is that it generates most of its revenue from advertising, which has come under threat from the Chinese government. New regulations over the last few years curbed Baidu's top-line growth in 2016, but the company is starting to pick up steam again.

While government regulations are always an overhanging risk for any Chinese stock, this actually plays in Baidu's favor, since it makes it unlikely that a foreign competitor can successfully penetrate the Chinese market, as Google tried to do before but failed

Baidu also faces ongoing competition from Tencent Holdings, which operates the largest social media platform in China. However, Baidu's dominant position in search has kept it well insulated from competitive threats so far, and that should continue to be the case.

What you need to know about MercadoLibre

On the other side, MercadoLibre is the leading online marketplace in one of the fastest growing e-commerce regions in the world, Latin America. In addition to its marketplace business, Mercado offers other services like payments (MercadoPago), shipping (MercadoEnvios), classifieds, and advertising. 

Mercado has built a powerful network-effect advantage with an active user base of 235 million. It has garnered more unique visitors in the region than cutthroat competitors like, Walmart, and Google Shopping. This makes Mercado the go-to marketplace in Latin America, since most buyers and sellers will naturally flock to where everyone else is shopping.

Which is growing faster?

Both Baidu and MercadoLibre are fast-growing companies. In the second quarter, Baidu reported revenue growth of 32% year over year, while Mercado posted growth of 18%. Mercado reports its results in U.S. dollars, so on a currency-neutral basis, Mercado grew 44% year over year in the last quarter. 

BIDU Revenue (TTM) Chart

BIDU revenue data by YCharts. TTM = trailing 12 months.

As for bottom-line growth, Mercado has been investing heavily to attract new active customers to its marketplace. As a result, the company has reported a net loss this year. However, it has managed to grow profits in the past, which is indicative of management's long-term goal to balance growth and profitability.

Baidu's earnings growth is looking strong, as its high-margin advertising business has posted robust growth lately. But like Mercado, Baidu is also investing to drive growth, especially in AI technologies and its Apollo unit. Additionally, management has planned for increased spending in the second half of 2018 to drive higher traffic in its core advertising business, which is expected to put pressure on the bottom line. 

BIDU Net Income (TTM) Chart

BIDU net income (TTM) data by YCharts.

Given the intent for both companies to continue investing in growth in the short term, Wall Street analysts expect Baidu's earnings to rise just 10.5% this year, while Mercado's earnings are expected to decline to a loss of $0.26 per share compared with a profit of $0.31 in 2017. 

Next year, analysts expect bottom-line growth for both companies to recover, with Baidu expected to grow earnings 12.5% and Mercado expected to return to profitability.

Which is the better buy?

Both companies have good long-term growth potential. I like Baidu's high-margin and fast-growing core advertising business, as well as its moon-shot opportunities in self-driving cars with its Apollo program. Also, Baidu is well positioned to capitalize on the Internet of Things with its DuerOS operating system -- which is growing rapidly, having reached 90 million users this year. 

MercadoLibre has a long runway of growth ahead, given that e-commerce in Latin America makes up less than 5% of total retail sales in the region. The company is seeing strong engagement from its user base, and its payments business is growing rapidly

Here's how both stocks match up on two popular valuation metrics:

Metric Baidu MercadoLibre
Forward P/E 17.2 258.9
P/Sales 4.86 9.3

Data source: Yahoo Finance!

I have to side with Baidu simply based on valuation. Baidu shares are cheap relative to its underlying growth with a forward P/E of just 17.2. Because of Mercado's investments in growth right now, its P/E is inflated due to lower earnings. But when comparing both stocks using the price-to-sales ratio, Baidu is still the better deal. Therefore, Baidu is the better buy today.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.