Walmart (WMT) - Get Report  positively crushed their earnings last month. They reported their 20th consecutive quarter of sales growth and beat on all the standard metrics that you'd expect a good earnings to entail: revenue of $130.38 billion vs. $130.11billion expected, EPS of $1.27 vs $1.22 expected and same-store sales ("comps") of 2.8% vs 2.1%. Just all around good. Walmart's 24% YTD return has also outpaced the S&P's 20% return.

And this isn't a one-off performance, Walmart has consistently outperformed its peers over the last five years on critical return metrics:

Image placeholder title

Source: MSN Money

But that isn't what augurs so well for Walmart, and isn't what makes me feel so confident in their direction long term: it's what they're accomplishing online. E-commerce sales rocketed 37% higher, and it substantially enhanced its grocery delivery service. Walmart now offers grocery delivery in over 1,100 locations and expanded its pickup locations to over 2,700.

There's a reason Walmart has stood its ground and grown in the face of Amazon's (AMZN) - Get Report onslaught, and that's because it continues to evolve to the new consumer paradigm that Amazon helped usher in. Speaking as a retail user: if you've never used Walmart (or its awesome e-commerce arm for groceries, you should. It's exceptionally convenient, cheap, and has free shipping for orders over $35. As a Manhattan resident, I don't understand why anyone pays the exorbitant local grocery prices here -- let alone the trek to and from the store -- when you have a Walmart with free 2-day shipping (next day cold-shipped groceries with in your room.

Even when I eventually move, there's no way I'm going back to brick-and-mortar shopping after experiencing the Amazon-esque shipping quality and even better prices that Walmart provides. This mode of grocery shopping is the future.

My consumer review aside, Walmart is a great buy off financials alone. But, should you really be adding another long to your portfolio when recession fears still persist, threatening the fantastic returns we've had this year as we sit near all-time highs? The beauty of this stock is it allows you to be economically agnostic; Walmart is a great investment if economic fundamentals remain intact, and it's also a one of the best choices if they break down.

One of the strongest performing sectors during a recession is consumer non-discretionary, because even when economic times are bad, people still buy toothpaste and groceries. The consumer can be quite reliable during a recession, and Walmart is a beacon of that strength when times are tough. Walmart has on average returned over 42% during the past five U.S. recessions, and was even able to eke out a positive year in the maelstrom of 2007. This stock participates in bull markets and is a shelter of returns in bear ones as well.

So if you're not interested in playing the macro guessing game and want a robust, growing, modern business that performs in good times or bad while providing a 1.83% yield, add some Walmart to your portfolio.

Amazon is a holding in Jim Cramer'sAction Alerts PLUS Charitable Trust Portfolio. Want to be alerted before Cramer buys or sells AMZN? Learn more now.

 The author has no positions in any of the stocks mentioned.