Baidu (NASDAQ:BIDU) and Alphabet (NASDAQ:GOOG) (NASDAQ:GOOGL) are two of the top names in online search. Baidu is the top search engine in China, while Alphabet's Google dominates most other markets.

But over the past five years, Alphabet's stock soared more than 130% as Baidu lost more than half its value. Let's see why that happened, and whether or not Alphabet will continue outperforming Baidu over the next few years.

A bull climbs a rising stock chart.

Image source: Getty Images.

How Baidu and Alphabet make money

Baidu generated 73% of its revenue from online ads last quarter. 26% came from its streaming video subsidiary iQiyi (NASDAQ:IQ), and the remaining 1% came from other businesses like cloud services and smart speakers.

Alphabet generated over 99% of its revenue from its main subsidiary Google last quarter. 84% of Google's revenue came from ads, while the remaining 16% came from Google Play, Google Cloud, its Pixel phones, and other products and services. The remaining sliver of Alphabet's revenue came from "other bets" like its driverless platform Waymo and its biotech unit Calico.

Which company is growing faster?

A comparison of the two companies' ad revenues over the past year indicates that Baidu is struggling much more than Google:

YOY Advertising Revenue Growth

Q3 2018

Q4 2018

Q1 2019

Q2 2019

Q3 2019

Baidu

18%

10%

3%

(9%)

(9%)

Google

20%

20%

15%

16%

17%

YOY = Year-over-year. Source: Company quarterly reports.

Baidu is struggling for three main reasons: a sluggish Chinese economy causing companies to cut their ad budgets, competition from rival ad platforms like Tencent's (OTC:TCEHY) WeChat, and certain industries (like healthcare, fintech, and gaming) facing tighter government oversight of their advertising practices.

Google's advertising revenue growth remained robust over the past year. In retrospect, its decision to exit mainland China after a clash with government regulators in 2010 now seems like a smart move.

However, Baidu's ad revenue improved sequentially for two straight quarters, while its traffic acquisition costs (TAC) accounted for less than 16% of its ad revenue in the third quarter, indicating that it wasn't spending too much cash to gain traffic. Google's TAC accounted for 22% of its ad revenue last quarter.

A search box floating over a laptop keyboard.

Image source: Getty Images.

Analysts expect Baidu's revenue to dip 2% this year but rebound 13% next year as its advertising business recovers. iQiyi, which offset its declining ad revenue in recent quarters, should also keep growing.

Alphabet is expected to post 19% sales growth this year and 18% sales growth next year. It's expected to maintain its duopoly in digital ads with Facebook across most markets, but Amazon is gradually gaining ground against both market leaders.

Which company is more profitable?

Baidu and Alphabet both rely on their higher-margin advertising businesses to subsidize the growth of lower-margin bets (like smart speakers and driverless cars) to expand their ecosystems.

That's a big problem for Baidu, because its ad business isn't growing. iQiyi also isn't profitable yet, so its revenue growth actually weighs down its margins.

As a result, Baidu's operating margin contracted eight percentage points annually to 8% last quarter. Alphabet's operating margin dipped just three percentage points to 23% last quarter, even as it continued to launch lower-margin hardware devices and invest in speculative side bets like driverless cars.

Baidu is streamlining its business by divesting non-core assets (like its fintech, meal delivery, and online travel investments), but analysts still expect its earnings to drop 56% this year before possibly rebounding 46% next year. Alphabet's earnings are expected to grow 6% this year and 17% next year.

The valuations and verdict

Baidu trades at 17 times forward earnings, while Alphabet has a forward P/E of 24. But Alphabet clearly deserves to trade at a premium to Baidu since it generates stronger growth at higher margins. Baidu isn't a lost cause yet, but it will remain a weaker investment than Alphabet until its core advertising business recovers.