Legendary investor Warren Buffett has successfully run the large conglomerate Berkshire Hathaway (BRK.A 0.55%) (BRK.B 0.50%) for more than five decades, generating some very compelling returns for investors along the way.

Between 1965 and 2021, Berkshire's stock price has gained an unimaginable 3,641,613%. That equates to a compound average annual gain of roughly 20.1%. The S&P 500, a benchmark for the broader market, has only generated a compound average annual gain of 10.5% including dividends.

But in recent times, Berkshire has actually had some off years compared to the broader market, although it is actually beating the market pretty handily this year. Let's take a look at Berkshire's more recent performance and see how much money you would have made had you invested $10,000 in the stock in 2012. I'll focus on Berkshire class B shares because they are more affordable than class A.

A snapshot of the last decade

Berkshire introduced class B shares in 1996 at 1/30 of the price of class A shares, to make them more affordable to smaller retail investors who wanted to get in on Berkshire's greatness.

Class B shares started trading at more than $1,000 per share and rose all the way to roughly $3,350 in 2010 before Berkshire did a 50-for-1 stock split, which made shares even cheaper. After the split, Berkshire class B shares began trading at about $73.

While Buffett has gotten older over the years, Berkshire has remained very active over the last decade. In 2013, Berkshire Hathaway teamed up with 3G Capital to purchase Heinz 2013 for $23 billion. Two years later, they would merge Heinz with Kraft to create the multinational food and beverage brand Kraft Heinz (KHC -0.99%).

This investment is widely known as one of Buffett's biggest mistakes, with the stock price of Kraft Heinz opening around $71 and currently trading below $39 today. "I made a mistake in the Kraft purchase in terms of paying too much," Buffett told CNBC in 2019.

Berkshire has also made other big acquisitions, such as its $4.7 billion purchase of the battery maker Duracell and the $4 billion purchase of the energy company Dominion Energy.

In terms of stock purchases in Berkshire's now roughly $328 billion equities portfolio, the conglomerate took a stake in Bank of America (BAC 0.92%) shortly after the Great Recession and has built America's second-largest bank into Berkshire's second-largest equity holding.

Another big moment for Berkshire came in 2016. It acquired a new position in the consumer tech giant Apple (AAPL -1.00%), which the company hasn't looked back on since, continuing to buy shares heavily in recent years. Berkshire's position in Apple is now valued at more than $136 billion and makes up more than 40% of Berkshire's equity holdings.

This year, Buffett and his team have been all about the energy sector, with rising gas prices. Berkshire has taken big stakes in Chevron (CVX -0.49%) and Occidental Petroleum (OXY -0.84%), and many suspect the conglomerate may look to eventually acquire Occidental outright. Here is how Berkshire's annual gains have stacked up to the S&P 500 since 2012.

Year Berkshire Hathaway S&P 500 W/Dividends
2012 16.8% 16%
2013 32.7% 32.4%
2014 27% 13.7%
2015 -12.5% 1.4%
2016 23.4% 12%
2017 21.9% 21.8%
2018 2.8% -4.4%
2019 11% 31.5%
2020 2.4% 18.4%
2021 29.6% 28.7%
2022* -2.04% -19.97%

Data source: Berkshire's annual letter. *= Year to date.

As you can see, Berkshire has won seven of the last 10 years, although it struggled in 2019 and 2020. However, unless things change dramatically over the last two months of this year, Berkshire is about to find itself back on a two-year winning streak against the S&P 500.

If you invested $10,000 in 2012, how much do you have now?

Berkshire class B shares started 2012 at about $77.38 per share. Currently, they trade for just under $295 per share, which equates to a gain of about 281%. That means if you invested $10,000 in 2012, you'd have about $38,100 now.

A popular S&P 500 index ETF started 2012 with a dividend-adjusted price of around $104 per share and recently closed at $376. That works out to a gain of roughly 262%. That means your $10,000 invested in this broader benchmark index would now be $36,200. So your investment in Berkshire would have yielded about $1,900 more than investing in the broader market.