Advanced Micro Devices (AMD 2.07%) (AMD) has been a beneficiary of the artificial intelligence (AI) boom, with the stock up an impressive 94% in the past three years (as of July 28). What's even more impressive is that it has been able to do so while playing little brother to Nvidia (NVDA -0.80%) in the graphics processing unit (GPU) space, a key component of data centers that makes AI possible.

On Aug. 5, AMD is set to report its fiscal second-quarter earnings, which many anticipate being solid. If revenue comes in around $7.4 billion, like the company estimates, it would've grown business by 35% year over year. Not too shabby at all.

This anticipated earnings growth has many investors wondering whether they should buy the stock before Aug. 5 to take advantage of a potential price boost. However, history says that might not be the best thought process.

A chart showng AMD's stock price movements relative to its earnings dates.

Beating earnings expectations doesn't equal immediate stock price growth

AMD is no stranger to beating earnings estimates. In its past 10 quarters, it has met or beaten earnings-per-share (EPS) estimates, yet there's been no consistency in how its stock price performs immediately after. This shows investors are considering more than just earnings when deciding how to value the stock. 

Anticipating how a stock's price will move based on earnings can often be counterproductive because the stock market doesn't behave rationally. A much better approach, if you believe in the company long-term, would be dollar-cost averaging to help offset some of the inevitable volatility.

Be prepared to pay a premium for AMD's stock

Whether you buy AMD shares before or after its Aug. 5 earnings, you should be prepared to pay a premium for the company. It's trading at over 43 times its forward earnings, which is higher than Nvidia, the leader in the space.

AMD PE Ratio (Forward) Chart
AMD PE Ratio (Forward) data by YCharts.

AMD's premium price isn't inherently a problem, but it makes it a lot harder to justify compared to Nvidia, which is growing revenue at a much faster pace. Trading at 40 times forward earnings is also expensive, but Nvidia's revenue in its last quarter increased 69% year over year, and it's the industry leader. 

While the ultimate decision to invest in AMD shouldn't revolve around Nvidia, it does help put the stock's valuation into perspective. In either case, approach the stock with a long-term mindset, and don't invest based on what you anticipate the stock will do post-earnings.