Image source: Getty Images.

It isn't hard to understand why Home Depot (HD -1.77%) and Sherwin-Williams (SHW 0.45%) suffered so greatly during the Great Recession. Fueled primarily by subprime lending practices, people didn't want to spend a dime on their houses while the entire real estate market was tanking.

But that same period also represented perhaps the best time to invest in each company. Indeed, since the depths of 2009, these two home-improvement specialists have offered investors spectacular returns.

SHW Total Return Price Chart

SHW total return price data by YCharts.

But which stock is the better buy today? That's a tough question to answer, especially because both represent ownership in top-notch companies. We'll do our level best to dig deeper below, evaluating each stock on three different variables.

Financial fortitude

Cash on hand is important -- there's no way around it. Tough times will come in the future for both Home Depot and Sherwin-Williams. There's no telling whether those times will be macro in nature or from self-inflicted wounds.

But when that time comes, companies that are cash-rich have options. They know they'll survive, and they can outspend rivals, keep paying their dividend, buy back stock on the cheap, and even make strategic acquisitions.

Debt-heavy companies are in the opposite boat -- forced to narrow their focus just to make ends meet and avoid bankruptcy.

Remembering that Home Depot is valued at over six times the size of Sherwin-Williams, here's how the two stack up in terms of financial fortitude.

Company

Cash

Debt

Net Income

Free Cash Flow

Home Depot

$3.6 billion

$22.3 billion

$7.7 billion

$8.4 billion

Sherwin-Williams

$0.7 billion

$1.9 billion

$1.1 billion

$1.3 billion

Data source: Yahoo! Finance.

Relative to their size, these two show almost identical numbers, with one exception: debt. While Home Depot's free cash flow makes it unlikely that it would face a financial pinch during normal economic times, it may feel a squeeze if the home-improvement market sours.

Sherwin-Williams, on the other hand, has a much more favorable cash-to-debt ratio. For that reason, I'm siding with the latter for this variable.

Winner = Sherwin-Williams

Sustainable competitive advantages

If I were forced to make all of my investment decisions based on a single factor, this would be it. A company's sustainable competitive advantage -- often called its "moat" by professional investors -- represents the thing that sets it apart from the competition. It is the special sauce that makes the company what it is.

The biggest advantages for both of these companies are their scale, market share, and brand value. Home Depot is the largest home-improvement store in America, coming in at 24% in the U.S. It is part of a virtual duopoly with Lowe's in what is still a highly fragmented market. The company's scale allows it to bargain for lower prices that it can then pass through to customers, and it also helps make the company's brand very familiar to anyone who has work to do on their house.

Sherwin-Williams takes a slightly different approach, selling its products through company-owned stores, as well as home-improvement venues like Home Depot. The company's acquisition of Valspar (NYSE: VAL) also makes it one of the biggest global paint companies by market share, coming in at 12% globally. Like Home Depot, this will help Sherwin-Williams get inputs for lower costs and pass those savings along to customers.

In the end, the moats at both of these companies are about as strong as they can be in an industry that relies heavily on scale and brand.

Winner = Tie

Valuation

Finally, we have valuation. This is part art, part science -- and has just as much to do with an individual investor's comfort level than anything else. Here are a number of metrics I consult when trying to evaluate a stock's valuation.

Company

P/E

P/FCF

PEG Ratio

Dividend

FCF Payout

Home Depot

22

20

1.6

2%

40%

Sherwin-Williams

22

20

2.2

1.2%

24%

Data source: Yahoo! Finance, E*Trade. P/E represents figures from non-GAAP earnings.

These two really couldn't be any more similar. Trading for identical multiples on both earnings and free cash flow, Home Depot gets the edge. The company is trading at about a 25% discount based on its earnings potential (PEG ratio). Both companies also offer healthy and sustainable dividends, but Home Depot's yield is significantly larger.

Winner = Home Depot

Final call = draw

So there you have it: As I said, this is a competition between two very high-quality companies -- and it shows. If I were forced to make a decision one way or another, it would probably be to side with Sherwin-Williams. The company's acquisition of Valspar gives it the type of global market share that can expose it to emerging markets. That's simply not something that Home Depot has.

But don't be mistaken: Both are high-quality holdings that are worthy of further investigation by interested investors.