Both Facebook (META -0.32%) and Amazon.com (AMZN 2.96%) have crushed the market in recent years. In the past two years, Amazon is up 129% and Facebook is up 92%. Further, both stocks hit new all-time highs this month. But with shares rising as fast as they have, is either stock still a buy? And, if so, which is a better bet?

To get an idea of these two stocks' investment potential, let's compare them side-by-side.

Company

Price-to-Earnings

Price-to-Sales

Year-Over-Year Revenue Growth (Trailing-12-Month)

Year-Over-Year EPS Growth (Trailing-12-Month)

Facebook

71

17

46%

63%

Amazon

287

3

23%

375%

Valuation

It's no secret that both Amazon and Facebook are priced with a premium valuation. The market has baked in both sustainable competitive advantages and continued growth for both companies. If this isn't already evident by their enormous market capitalizations of $332 billion for Facebook and $329 billion for Amazon -- market caps typically reserved to companies usually with tens of billions of dollars in annualized profits -- just take a look at the two companies' valuation metrics.

Facebook CEO Mark Zuckerberg. Image source: Facebook.

Both Facebook and Amazon's price-to-earnings metrics are off the charts, at 71 and 287, respectively. With metrics like these, investors are pricing in both continued revenue growth, which will support further EPS improvements, and significant profit margin expansions. In other words, investors expect the two companies to benefit from meaningful scale as they continue to grow.

Facebook and Amazon's price-to-sales metrics, however, arguably serve as more useful barometers than P/E when trying to peg just how optimistically the two growth stocks are priced. But since both companies are in totally different industries, these metrics should be compared to industry peers -- not to each other. While Facebook's price-to-sales ratio of 17 trumps Amazon's valuation at 3 times sales, the industry average for Facebook's peers is around 7.1, and the industry average for Amazon's peers is about 1. So when it's viewed next to other Internet service companies, the market has been comparatively more generous to Facebook than to Amazon.

Growth

But the market's premium forward-looking valuation for Facebook compared with Amazon's makes sense: Facebook is growing much faster than Amazon. Facebook's revenue is up a whopping 46% in the trailing-12-month period. That doubles Amazon's 23% year-over-year growth during the same period.

What about Amazon's monstrous EPS growth? Investors should be careful not to extrapolate this 375% year-over-year growth in the past 12 months. While the big jump in EPS is notable, it's far from sustainable. In the year-ago period, Amazon was still stuck in a drawn out five-year period of bouncing back and forth between profits as the e-commerce giant prioritized growth over margin. But during the trailing 12 months, economies-of-sale milestones, growing sales from Amazon Web Services, and an increased focus on profits drove net income to a meaningful level, giving the company a net margin of 1.03% -- finally close enough to Wal-Mart's net margin of 3% to imagine Amazon operating more profitably than Wal-Mart's brick-and-mortar model.

Currently, the best way for investors to examine growth trends of Facebook and Amazon is to look at their revenue growth. With Facebook's revenue up 46% in the trailing-12-month period and growing at an average rate of 56% during the past five years, the social network is clearly still benefiting from strong growth in mobile ad spending. Amazon's trailing-12-month revenue growth of 23% and its five-year average annual growth of 26% also highlight a sustained growth streak -- albeit one well behind Facebook's -- likely to persist.

The verdict

A quick review of Facebook and Amazon's valuations and recent growth suggests neither stock is a screaming steal at these prices. Yes, Amazon's valuation is arguably more conservative than Facebook's, but Amazon is also growing revenue at about half of Facebook's rate. And both stocks are priced for sustained rapid growth for years to come, making them less attractive.

With the stocks near all-time highs, I'd avoid both. However, just because neither stock looks like a strong buy, that doesn't mean current shareholders should bail out. As long as these companies continue to meet or exceed shareholder expectations, these aren't the sort of businesses I'd be trimming from my portfolio.

And for investors who are interested in these stocks but haven't pulled the trigger, these A-performers are at least worth adding to a watchlist.