A bear market becomes official when the price of an asset or index falls by 20% or more. Since the technology-centric Nasdaq-100 market index has declined by 28% so far in 2022, it fits firmly within that criteria. 

But a 28% loss doesn't accurately reflect the experience of most tech investors this year, because many individual stocks have collapsed by 50% or more. That's why it's important to be selective when investing in a bear market -- even if a particular company looks cheap because of its beaten-down stock price, it might not be in reality. 

Here are two stocks on opposite ends of the spectrum. One is beating the broader market in 2022 and might be worth buying, while the other is heavily underperforming and should probably be avoided.

The stock to buy: Splunk

Splunk (SPLK) is a data platform of the future thanks to its use of machine learning to deliver real-time insights to its business customers. While its stock has declined by 17% in 2022, it's still outperforming the Nasdaq-100 by 10 percentage points.

Splunk has collected an impressively diverse portfolio of customers, serving 90 of the Fortune 100 companies. Global car manufacturer Honda uses Splunk's predictive analytics to prevent equipment failures and the costly shutdowns that can result. And beer brewery Heineken uses the platform to link its 4,500 applications to gain a bird's-eye view of operations and extract valuable insights from 25 million monthly data points that are generated across them.

The point is data is an extremely valuable byproduct of the digital age, where companies run the bulk of their operations online, and Splunk is the value-extraction tool.

Splunk now offers its tools in the cloud, which makes them far more accessible, and it has supercharged the company's growth. In the first quarter of fiscal 2023 (ended April 30), cloud revenue jumped 66% year over year compared to a 34% increase for the company's total revenue. As a result, the cloud has grown to account for 48% of Splunk's business, whereas it was 38% just a year ago.

Splunk now has 329 customers spending $1 million or more annually on cloud services, up 62% from this time last year. It's also one of a small number of companies that have actually increased guidance recently, despite tougher economic conditions. It now expects to deliver up to $3.35 billion in full-year revenue in fiscal 2023. 

Splunk isn't profitable just yet, which remains a risk for investors. But it's still expanding quickly and building scale, so it makes sense for management to continue investing in growth for now. For investors, Splunk's focus on machine learning and big data makes it a solid long-term bet on the future.

The stock to sell: DoorDash

While Splunk's business is accelerating, DoorDash's (DASH 1.06%) is suffering a slowdown in many respects. The food delivery giant was a big beneficiary of pandemic restrictions because it was one of the only ways consumers could get their hands on their favorite restaurant foods. But although the pandemic continues, societal conditions are mostly back to normal, so DoorDash is struggling to generate the same growth it once was.

It's the main reason the company's stock has declined by a whopping 51% this year.

In the first quarter of 2021, DoorDash experienced 222% growth in its marketplace gross order value (GOV) compared to the first quarter of 2020. It's an important metric to watch because it measures the total value of all customer orders placed on the DoorDash platform for the given period. In Q1 2022, marketplace GOV came in at $12.1 billion, which represented growth of just 25% year over year -- a notable slowdown. 

It's still a respectable rate of increase, but there's a glaring problem. DoorDash failed to make a profit when its business was booming during the worst of the pandemic, and its losses continue to mount. In fact, it lost $167 million in Q1 2022, which was a 51% increase compared to the same period last year, despite the company generating record-high quarterly revenue of $1.4 billion.

The simple fact is that food delivery is a highly competitive industry and there are very few barriers to entry, which means DoorDash struggles to differentiate its business from other players. One of the few ways to gain an edge is to charge the lowest fees, but that comes at the cost of sustained losses. As a result, marketing is the company's largest operating cost, coming in at $414 million in Q1 2022, or 29% of revenue.

There's nothing to suggest the environment for DoorDash will improve any time soon, but the company does have $3.7 billion in cash, equivalents, and short-term investments on its balance sheet, so it has a lengthy runway to figure things out. However, it's probably not the stock to bet on in the depths of a bear market given its numerous challenges.