Over the past few years, Warren Buffett broke his tradition of avoiding tech stocks by adding shares of IBM (IBM 0.44%) and Apple (AAPL 0.70%) to Berkshire Hathaway's (BRK.A -0.39%) (BRK.B -0.22%) portfolio.

Buffett started buying IBM back in 2011, believing that then-CEO Sam Palmisano's plan to double Big Blue's EPS by 2015 would pay off. He started buying Apple in 2016, and later told Berkshire's shareholders that he invested in the company because people "build their lives around" the iPhone and that they "don't want the cheapest product."

A bull and a bear face off.

Image source: Getty Images.

But earlier this year, Buffett sold about a third of his stake in IBM, stating that he "revalued it somewhat downward" in comparison to six years ago. Yet Buffett nearly tripled his stake in Apple in the first half of the year. Should you follow the Oracle's lead by selling IBM and buying Apple?

How fast are IBM and Apple growing?

IBM has posted 21 straight quarters of annual revenue declines. Its revenue fell 2% last year, and analysts expect a 3% decline this year. The story was a familiar one -- its higher-growth "strategic imperatives" (cloud, mobile, social, security, and analytics) weren't growing fast enough to offset the ongoing declines at its older business hardware and software businesses.

Meanwhile, the growth of IBM's strategic imperatives has been slowing down, indicating that rivals like Amazon, Microsoft, and Alphabet's Google are causing damage. Those businesses, which accounted for 43% of IBM's top line, posted just 11% annual sales growth last quarter versus 12% growth in the first quarter. If that figure comes in even lower when IBM reports its third quarter earnings on Oct. 17, investors might lose faith in its top line growth ever recovering.

The iPhone X.

The iPhone X. Image source: Apple.

Apple's revenue growth has been rosier than IBM's. Its revenue slipped 8% in 2016 due to its first ever decline in iPhone shipments, but is expected to rise 6% this year on higher sales of its new iPhone 8, 8 Plus, and X models. However, Apple was criticized for the confusing introduction of the three models, and some industry watchers aren't sure if the initial weak demand for the iPhone 8 should be attributed to anticipation for the iPhone X or waning interest in Apple's annual upgrades.

The latter would be a crushing blow to Apple, which generated 55% of its revenue from the iPhone last quarter. Meanwhile, multiple reports indicate that the iPhone X could be delayed past its Nov. 3 launch date, with some analysts claiming that it won't be readily available until 2018. That's why Apple has been investing heavily in the growth of its Services (Apple Music, Apple Pay, iTunes, and other services) business, which posted 22% annual sales growth and accounted for 16% of its top line last quarter.

How profitable are IBM and Apple?

IBM never fulfilled Palmisano's promise to hit $20 in earnings per share by 2015. But IBM's attempts to hit that target resulted in lots of divestments and job cuts, and caused it to miss big investment opportunities in the cloud and mobile space -- a course which wouldn't be reversed until Ginny Rometty replaced Palmisano in 2012.

Rometty still uses cost cutting measures and buybacks to prop up Big Blue's earnings amid revenue declines, but at a less aggressive pace than her predecessor. As a result, IBM's earnings slipped 9% last year and are expected to rise just 1% this year.

Apple's earnings fell 10% last year due to the aforementioned iPhone slowdown, but analysts expect 8% growth this year on stronger iPhone sales and the expansion of its higher-margin services. However, that growth forecast might need to be revised if the iPhone X hits significant production delays.

Like other mature tech companies, Apple uses buybacks to boost its earnings. The company spent $30.6 billion on buybacks over the past 12 months -- which was a smart move since the stock rallied nearly 40% during that period.

Valuations and dividends

IBM trades at 12 times earnings compared to the industry average of 20 for IT services companies. Apple has a P/E of 18, which matches the industry average for consumer electronics companies.

IBM pays a forward dividend yield of 4.1%, which is supported by a payout ratio of 41%. Apple's forward yield of 1.6% is supported by a lower payout ratio of 27%. IBM has hiked that payout annually for 17 straight years, while Apple has done the same for the past four years.

The verdict: Stick with Apple

I believe Apple is a better long-term play than IBM since IBM still hasn't offered investors a viable path toward growing its revenues again. Apple is too dependent on the iPhone, but it's taking the necessary steps to secure and expand its ecosystem with subscription-based services and new products. Therefore, I think Buffett made the right choice -- although IBM offers a lower valuation with a higher dividend.