For investors looking for fast-growing tech companies with room for more growth, look no further than social network Facebook (META 2.86%), and China's dominant search engine Baidu (BIDU 1.47%). Making these two companies even more attractive prospective investments is the fact that both companies are already profitable.

But is either stock a buy? And if so, which is a better buy?

Facebook
The problem often plaguing fast-growing tech stocks is their valuation. Facebook is no exception. The market has awarded the stock with a significant premium, pricing in considerable growth in the future.

On the flip side, however, Facebook's recent growth, when paired with its business' durability, merits a premium valuation. The question is, therefore, whether or not Facebook's ability to grow its business is impressive enough to make paying a huge premium for the stock worthwhile.

The first thing investors need to know about Facebook is just how impressive its recent growth has been. For three quarters in a row, the social network's year-over-year revenue growth rates have actually accelerated, jumping from a year-over-year growth rate of 39% in Q2 to 52% growth in Q4.

And Facebook managed to grow its profitability significantly, too, reporting a 49% year-over-year boost in its non-GAAP EPS in its most-recent quarter. Further, Facebook's absolute profits are significant: Its fourth-quarter GAAP and non-GAAP net income was $1.6 billion and $2.3 billion, respectively.

Unfortunately, however, the premium investors have to pay to buy Facebook shares today is so significant that even this recent growth isn't enough to make the stock a clear buy. With the stock trading at about $109 at the time of this writing, the social network trades at about 84 times earnings.

Baidu
Unlike Facebook, Baidu's stock trades at a more-reasonable valuation, even as it continues to grow rapidly.

Image source: Baidu.

With revenue up 33% in its most-recent quarter, and up 35% for the entire year compared to respective year-ago periods, Baidu's top line is growing fast -- but not as rapidly as Facebook's.

When it comes to profitability, however, Baidu is actually struggling to grow at all. In the company's most-recent quarter, Baidu's diluted earnings per ADS -- when excluding the company's net gain from its exchange of Qunar shares with CTRIP -- was 7.61 RMB, or $1.18 per share. This compares to $1.45 per ADS in the year-ago quarter. Baidu's aggressive move into faster-growing, lower-margin businesses, such as streaming video and app market places, means costs are growing faster than revenue for now -- and this is pressuring profitability.

Over the long haul, Baidu management expects its profitability will resume growth. But given the speculative nature of management predicting that it can return to meaningful profitability growth, relying on this forecast heightens the risk of owning the stock.

With a price-to-earnings ratio of about 38, when excluding Baidu's fourth-quarter benefit from its net gain from Qunar shares, its P/E ratio is significantly lower than Facebook's. But the added risk in relying on Baidu to find a way to return to meaningful earnings growth offsets any potential benefit from the stock's lower price-to-earnings ratio than Facebook's.

Overall, Facebook's ability to grow both revenue and EPS significantly does a better job justifying the social-network stock's P/E ratio of 84 than Baidu's solid revenue growth -- yet uncertain outlook for profitability -- does justifying its adjusted P/E ratio of 38. Still, both stocks' expensive price tags leave neither looking like a clear buy at these levels.

If an investor was forced to buy either stock, Facebook looks like the better bet. But I'd personally kick both of these stocks to my watchlist for now, hoping for a sell-off to make them more attractive.