NEW YORK (TheStreet) -- Worldwide soda consumption has been declining for a couple of years, but that hasn't kept global beverage giant PepsiCo (PEP) - Get PepsiCo, Inc. Report from rewarding investors with 35% stock gains in the past three years.

That may not impress when compared to the 40% three-year gains of the Dow Jones Industrial Average (DJI) . But New York-based Pepsi, which will report second-quarter earnings Thursday, has done more than enough to dominate its larger chief rival. Coca-Cola (KO) - Get Coca-Cola Company Report has delivered a meager 2.3% gain in the past three years, and there are signs that Pepsi will continue to widen its lead in the quarters and years ahead.

"We have momentum," said Hugh Johnston, Pepsi's chief financial officer, in February. "We are absolutely rolling right now," he added, regarding Pepsi's growth among U.S. retailers.

Johnson's upbeat assessment is actually an understatement, given that Pepsi has strung together 17 consecutive earnings beats. You would have to go all the way back to its fourth quarter of February 2011, dating more than four years to find the last time Pepsi didn't exceed the average analyst earnings estimate. And I wouldn't bet my own money that its streak will end Thursday.

For the quarter that ended in June, Pepsi is projected to earn $1.24 a share on revenue of $15.8 billion, translating to declines of 6% and 6.5%, respectively. For the full year, ending in December, earnings are projected to decline 2.5% year over year to $4.51 a share, while revenue of $63.6 billion is projected to decline 4% year over year.

These numbers reflect the new reality of the soda industry. According to Beverage Digest, U.S. soda consumption is at its lowest (per capita) since 1986. And with consumers moving towards healthier beverage alternatives like tea and water, soda demand is not expected to climb any time soon.

TheStreet Recommends

But this underscores how impressive Pepsi's results have been in the past four years, as it has figured out ways to grow both revenue and profits despite this shrinkage in its core business.

How has Pepsi done it? Unlike its Coca-Cola, Pepsi is well-diversified: Snack food brands such as Frito-Lay and Doritos, as well as packaged food brands like Lipton and Quaker, make up some 52% of its revenues. With those in its arsenal, Pepsi can offset its slumping soda sales and still deliver core revenue buoyed by better volumes and higher prices.

Coca-Cola, on the other hand, has struggled with lack of diversification. Seeking new revenues to offset declining soda demand, Coca-Cola has bought stakes in fast-growing beverage businesses such as Keurig Green Mountain (GMCR) and Monster Beverage (MNST) - Get Monster Beverage Corporation (MNST) Report. But Keurig Green Mountain now has its own set of problems, and its stock has declined more than 40% this year.

At the same time, Pepsi continues to bet on itself and its growth prospects. It recently announced plans to buy back $12 billion worth of its shares over the next three years. Pepsi also raised its annual dividend by 7.3% to $2.81 per share.

All told, the company expects to return some $9 billion to shareholders through a combination of dividends and buybacks in 2015, making Pepsi a must-own stock for the next three years. The stock trading at around $94, the average analyst rates Pepsi stock as a buy with a 12-month price target of $108, suggesting 14% gains from current levels. So, the shares, which are up less than 1% on the year, are poised to pop with another earnings beat Thursday.

This article is commentary by an independent contributor. At the time of publication, the author held no shares in any of the stocks mentioned.