Shares of Twilio (TWLO 0.10%) and Matterport (MTTR -0.22%) have taken a brutal beating on the market so far this year, with both tech stocks having lost close to 70% of their value as of this writing.

However, their steep declines mean that savvy investors have an opportunity to buy these fast-growing companies at attractive valuations. A closer look at the markets that Twilio and Matterport serve will show us why these companies are worth buying and holding on to for a long time.

1. Twilio

Twilio stock's 67% drop so far in 2022 has brought its price-to-sales ratio down to 4.6. That's a nice discount when compared to Twilio's five-year average sales multiple of 16.8.

Buying Twilio at this multiple looks like a no-brainer given its terrific growth. The company released its second-quarter 2022 results on Aug. 4, posting a 41% year-over-year increase in revenue to $943 million. Twilio's non-GAAP net loss of $0.11 per share was the same as in the prior-year period.

The impressive top-line showing was driven by a mix of healthy growth in customer count and an increase in customer spending. The cloud communications specialist finished the quarter with 275,000 active customer accounts, a nice jump over the year-ago period's 240,000. Twilio also reported a dollar-based net expansion rate of 123%.

A reading of over 100% in the dollar-based net expansion rate means that Twilio's customers are spending more money on its offerings. More importantly, the company's guidance indicates that its growth streak is here to stay.

Twilio anticipates 31% revenue growth this quarter to $970 million. While Wall Street was anticipating slightly stronger growth, investors should note that Twilio has a history of delivering better-than-expected numbers. What's more, investors should consider looking beyond Twilio's near-term performance as the company is operating in a market that's built for long-term growth.

The cloud-based contact center market that Twilio operates in is expected to be worth nearly $55 billion by 2027 as compared to an estimated $17 billion this year, clocking a compound annual growth rate of 26%. Analysts expect Twilio's revenue to increase 36% in 2022, indicating that the company is set to grow at a faster pace than its end market.

In all, Twilio's solid customer base and the robust adoption of its solutions puts it in a nice position. Investors looking to buy a beaten-down tech stock that could supercharge their portfolios in the long run should take a closer look at Twilio.

2. Matterport

Matterport stock is down 70% so far in 2022, but investors heaved a sigh of relief on Aug. 10 when the company released its Q2 numbers. Shares of the company whose hardware and software solutions help customers capture real-world physical objects in the form of three-dimensional (3D) virtual models across various industries shot up big time following its latest results.

That's because Matterport delivered an impressive outlook for the current quarter. The company forecasts $36 million in revenue this quarter along with a non-GAAP net loss of $0.14 per share. The midpoint of Matterport's revenue guidance would translate into 30% revenue growth over the year-ago period.

The company anticipates full-year revenue of up to $135 million. Matterport delivered $111 million in revenue last year, so its top line is on track to grow 17% this year at the midpoint of its estimate. Analysts expect Matterport to clock annual earnings growth of 26% per year for the next five years.

It is not surprising that analysts expect such impressive growth from Matterport. The demand for the "digital twins" that Matterport's solutions help create is booming. According one report, the digital twin market is expected to clock annual growth of 39% through 2030 and generate over $155 billion in revenue at the end of the forecast period.

Matterport is in a nice position to take advantage of this massive opportunity and has digitized a total of 24 billion square feet of space .

Matterport stock is trading at 14 times sales, which is not cheap but is lower than last year's multiple of 46. And the company has plenty of room to run.