Predicting when exactly a bear market will end is practically impossible, so investors are left watching and waiting right now as the benchmark S&P 500 index languishes down 20% in 2022. But here's the good news: We do have the benefit of nearly a century's worth of data that offers clues as to when this difficult period might be over.

Going back to 1929, the average S&P 500 bear market lasted 289 days (or nine and a half months). Given that the current one became official on June 13, it has already spanned a little more than six months, which implies we could be about three months away from the end.

But it might not be that simple. Soaring inflation is a headwind to the U.S. economy, and although there are signs it's slowing down, it could continue to impact the stock market in the short term until the inflation rate moves closer to the Federal Reserve's annualized target of 2% (it's currently 7.1%).

Nonetheless, some companies continue to outperform. Two of them are Duolingo (DUOL 7.28%) and Datadog (DDOG 3.58%), and here's why the current bear market might be a great time to buy these two stocks.

1. Economic slowdown? Not for Duolingo

With inflation soaring and interest rates on the rise, household finances are being squeezed, which is bad news for a company like Duolingo, which derives all of its revenue from consumers. At least you would think so -- the education-technology powerhouse is actually growing its revenue at the fastest pace of 2022 right now.

Duolingo has developed the most successful mobile app-based language education platform in the world. The app has been downloaded more than 500 million times, and users appear to love the app's gamified approach that makes learning a more enjoyable and less strenuous experience.

In the third quarter, Duolingo's monthly active users soared by 35% year over year to 56.5 million, a record high. But its paying user base topped 3.7 million and grew at a much faster pace of 68% as the company's monetization efforts continue to gain traction. Users can improve their free learning experience with a paid subscription, which unlocks additional features and enables faster progress through the lesson bundles.

Duolingo's revenue jumped 51% in Q3, marking the fastest growth rate of 2022 so far. The company generated $338 million in revenue over the past four quarters, but it considers its addressable opportunity to be $23 billion this year -- so it has barely scratched the surface -- and that figure could double to $47 billion by 2025.

Investors who buy Duolingo stock right now will own a company that is firing on all cylinders even amid a weak consumer environment, and that still has a lengthy runway to grow despite already leading its industry. The stock is down about 33% this year, but when the bear market eventually ends, it could be primed to soar.

2. Datadog hiked its 2022 sales forecast by $100 million

Even in the face of a challenging economic climate, Datadog's quarterly results continued to come in hot, prompting the company to increase its revenue guidance three times this year. Datadog is an increasingly useful tool for any business with a digital presence; its platform monitors cloud-based networks and infrastructure to deliver unique insights that can help improve technical efficiency and customer satisfaction.

Say a business operates a global e-commerce website. Occasionally, the site might suffer an outage or a slowdown in one corner of the world, which won't be visible until those customers either complain or simply stop buying products. In other words, the business won't know until it's already lost money. Datadog actively prowls for such technical issues and can alert the operator almost immediately, enabling a rapid response before the customer experience is affected.

Datadog now serves multiple industries including healthcare, gaming, and financial services.

At the end of the third quarter, the company had 2,600 customers who are spending at least $100,000 annually. That was a 44% jump from the same time last year, and it highlights how essential cloud monitoring tools are to large organizations, which tend to have more complex online operations and more expansive digital touchpoints with consumers.

Datadog's third-quarter revenue came in at $437 million -- not only was that an increase of 61% year over year, but it was also a whopping $23 million above the company's prior guidance (at the top end of the range). This was a consistent theme throughout 2022, and Datadog has now increased its full-year revenue forecast by $100 million in three separate upward revisions.

It raises the question: If Datadog's business is performing so well in this tough economy, how will it perform when the situation improves? There are already signs that 2023 could be more favorable for businesses as inflation appears to have peaked. Investors might wish they'd taken the chance to buy Datadog stock during this bear market, considering it's down 55% this year amid the broader tech sell-off.