Costco (NASDAQ:COST) is America’s largest wholesaler by revenue and is closely watched by investors and consumers alike as a sign of how the economy is doing in general. If folks flock to Costco for deals in bulk, it’s probably not good news for most family budgets. If Americans spend more on name-brand and upscale products instead of the no-frills items at COST, it’s a sign consumers have more money to burn.

It should come as no surprise that Costco has been doing pretty well recently amid high unemployment and consumer spending woes — COST is up about 15% so far in 2011 while the Dow Jones is down about 4%, and Costco is up almost 30% in the past year.

But more interesting is the fact that Costco isn’t just riding this broader economic trend to bigger profits, but also stealing customers away from low-price rivals — specifically, retail behemoth Wal-Mart (NYSE:WMT).

Here’s the rundown on Costco if you’re not familiar with its business model: Yes, its core business is pushing huge volumes of low-cost products through its bare-bones warehouses. But margins are better than you think because the company charges (and strictly enforces) membership dues — a great source of revenue. Couple this with low overhead (pallets of goods often are just placed unceremoniously on bare concrete floors) and you can understand why the company manages to squeeze out high returns on its asset base despite a “race to the bottom” pricing mentality.

The strength of Costco shows in its recent numbers. Take a look at the revenue by quarter across the past three years (the last quarter and full year for fiscal 2011 are estimates):

That was 9% revenue growth in 2010 and an estimated 13% this year.

Earnings also have been moving handily upward, too, from $2.47 EPS in fiscal 2009 to $2.92 in 2010 and $3.30 targeted for 2011. That’s 18% earnings growth in 2010 and 13% targeted for this year.

Surely some of this growth has been because of cost-conscious consumers moving away from higher-priced options. But this isn’t the only tale of the ticker tape, here. The fact is that while more Americans are looking for low prices, they also are being choosey among the discounters — with Costco one of the winners, and companies like Wal-Mart winding up the losers.

In August, Wal-Mart suffered its ninth consecutive quarter of same-store sales decline in the U.S. That’s more than two years of falling sales — and across a period of time where, let’s admit it, consumer spending hasn’t exactly been on the rebound. The stagnant sales have resulted in stagnant shares — WMT stock is down about 3% this year, and has been basically flat since early 2009.

So will the same story bear itself out this week with Costco’s year-end report and subsequently with Wal-Mart numbers a month later when it reports quarterly earnings in November? Probably. According to Thomson Financial, in the past 30 days, three Wall Street analysts have revised their earnings targets up for Costco on the quarter — with five analysts raising the bar on full-year expectations. Considering the already impressive growth that is plotted for Costco, further upward revisions are a good sign.

And Wal-Mart? Well, the retailer also is plotting revenue and earnings growth on the quarter. But the most recent analyst move was a from Deutsche Bank (NYSE:DB), which initiated coverage on Wal-Mart with a “sell” rating and a target of $48. That’s another 8% decline from here.

Expect this trend to continue — including more pep for Costco shares after what should be an impressive year-end report this week, and more trouble ahead for Wal-Mart.