As a member of the Magnificent Seven, Alphabet (GOOG 0.56%) (GOOGL 0.66%) crushed the market this year. Shares are up nearly 60%, while the S&P 500 has returned just 15%. With the hype around artificial intelligence (AI) at a fever pitch, investors have piled back into big technology stocks in a huge way.

If you bought Alphabet shares last year or have held the stock for a long time, you might be considering locking in your gains at these elevated prices. Conversely, if you've never owned the stock, you probably are wondering whether you've missed the boat on these impressive returns. Let's run through the numbers and see whether Alphabet is a buy or sell at these prices. 

GOOG Total Return Level Chart

GOOG Total Return Level data by YCharts.

A tale of two years

Last year was one of the toughest periods in Alphabet's history. After a phenomenal 2021, the company saw big slowdowns in its growth in 2022, with many companies pulling back on their marketing budgets. For example, in the second quarter, Alphabet's revenue "only" grew 16% year over year in constant currency. That is a big slowdown from the 57% growth it put up in 2021.

With a rapidly growing employee base, Alphabet's expenses started growing faster than revenue last year, leading to margin compression. On a trailing 12-month basis, Alphabet's operating margin collapsed from over 30% to around 25% in just a few quarters' time. This led to a major drawdown in Alphabet's share price. In fact, the 45% collapse was the largest in Alphabet's history as a public company. Previously, it had never fallen by more than 30% from all-time highs.

This year, the stock recovered most of these gains. Why? Well, for one, there is the market narrative around AI. But besides that, Alphabet has shown an ability to start trimming its costs and focus on shareholders again. It went through a major layoff early last year and is now seeing its operating margins rise. Last quarter, its operating margin was 29% versus 28% in the second quarter of 2022. Revenue growth has also started to recover, growing 9% on a constant currency basis last quarter versus 7% in the fourth quarter of 2022.

Add these three things together, and it is no surprise to see Alphabet shares crushing the market in 2023.

What will revenue growth be this decade?

Short-term developments can be useful, but if you want to own a stock for the long term, the most important things are long-term revenue growth and profit margins. I have no problem betting that Alphabet's profit margins will remain high due to the automated nature of its digital advertising business. As long as management doesn't overhire again, things will be fine here.

So that leaves revenue growth. Many investors are skeptical that Alphabet can keep growing its revenue at close to double digits, with its revenue already at $289 billion. I am a bit more optimistic. The global advertising industry is estimated to be $874 billion and growing 5.4% a year, generally a little faster than global GDP. If Alphabet just maintains its market share, it should be able to ride this tailwind for the rest of this decade.

But most readers are aware that Alphabet is a leader in digital advertising, which is taking share from legacy forms of entertainment. Its YouTube asset has billions of users and is the leading video platform among smartphones, tablets, and TVs. This decade, the billions of dollars spent on legacy TV advertising will shift over to digital formats. A lot of this money will go to YouTube.

Let's not forget Alphabet's cloud division, Google Cloud. The segment is growing revenue by 28% year over year and hit $8 billion in sales last quarter. With a huge opportunity ahead of it to capture the transition from on-premise to cloud computing infrastructure, this segment can help drive Alphabet's revenue growth this decade as well. Combined, I think it is clear that the company can put up around 10% revenue growth every year for at least the next few years. 

So, should you buy or sell?

I'm going to cheat on this answer and say you should not buy or sell Alphabet at these prices. Even though the business should durably grow, the stock looks expensive at a price-to-earnings ratio (P/E) of close to 30. Flip that around, and the stock has an earnings yield of just 3.3%. Short-term Treasuries currently yield 5.5%. Of course, Alphabet's earnings yield should grow, but there is a lot of risk in buying shares of Alphabet at these prices. Investors are probably better suited to wait for the shares to hit a P/E of 15 to 20, which is where they traded at the start of this year.

But if you wouldn't buy the stock, shouldn't you sell it? Not necessarily. For long-term owners of Alphabet, it might be unwise to sell your shares just because the earnings ratio is slightly elevated because of capital gains taxes. The rates vary based on what account your shares are in, what tax bracket you belong to, and whether the gains are short-term or long-term, but capital gains can eat a lot into your investment returns. That is why I think -- counterintuitively -- investors shouldn't be buying or selling Alphabet here. But you definitely should keep this high-quality business on your watchlist.