If you've owned it over the years or just followed the markets, you know that Berkshire Hathaway (BRK.A 1.66%) (BRK.B 1.35%) has been a solid investment.

Since legendary investor Warren Buffett took over the company in 1965, Berkshire has soundly beaten the market over a long period of time. Between 1965 and 2022, Berkshire's stock has generated compounded annual gains of 19.8% versus the broader benchmark S&P 500's 9.9% including dividends over the same time frame.

Still, it's interesting to look at how Berkshire has stacked up over different periods of time, especially more recently. If you invested $4,500 in Berkshire's stock in 2015, here's how much you would have today.

Warren Buffett.

Image source: Motley Fool.

How Berkshire has built the business

As it has done for decades, Berkshire has made several acquisitions during this time period. In 2017, Berkshire acquired the large metal fabrication company Precision Castparts, which specializes in making equipment for the aircraft industry, for more than $32 billion in one of its largest-ever acquisitions.

Unfortunately, the move has not exactly paid off like Buffett might have hoped, largely due to the pandemic. In 2020, Berkshire wrote off close to $10 billion of Precision Castparts' value. That also came as Berkshire sold all of its airline stocks.

In his 2020 annual letter to shareholders, Buffett said that Precision is "a fine company -- the best in its business." However, Buffett also acknowledged that he was "simply too optimistic about PCC's normalized profit potential."

In 2016, Berkshire also made another big move that would alter the company's trajectory. In the first quarter, Berkshire opened a stake in large consumer tech giant Apple. Buffett reportedly first got interested in Apple when one of his friends lost their iPhone and he saw how distraught his friend was, and therefore how big of a part of his life the phone was.

Once Berkshire started buying Apple stock, the company didn't stop, which is consistent with Berkshire's all-in investing approach when it sees opportunities. Apple now makes up more than 44% of Berkshire's portfolio. The stock has climbed close to 500% since the beginning of 2015.

Berkshire's moves since the pandemic began have been pretty well documented. As I mentioned, the company sold its airline stocks and a lot of its bank stocks as well. Meanwhile, Berkshire has loaded up in the energy sector, outright purchasing some energy companies, as well as big stakes in Chevron and Occidental Petroleum. This is against the backdrop of Russia beginning its invasion of Ukraine, which has put pressure on the global oil supply.

If you invested $4,500 in 2015...

While the market has been extremely topsy-turvy since the pandemic began, Berkshire's stock has performed pretty well since the start of 2015. At the beginning of that year, class A shares of Berkshire traded around $227,000 per share. Today, they trade around $478,000, for a gain of nearly 111%.

That means the $4,500 invested at the very start of 2015 is now worth $9,450 today. Had you invested the $4,500 in the S&P 500 in 2015, which is now up about 99% at today's level, that money would be worth slightly under $9,000. This means Berkshire has outperformed the broader market since 2015.