This was a tough year for restaurant stocks, and the pain was widespread for investors. Popular IPOs Noodles & Co. and Potbelly tanked by 27% and 49%, respectively, while established giants also felt the pinch. Fast-food king McDonald's badly trailed the market and fast-casual Panera Bread lagged.

Still, a few restaurant stocks bucked the negative trend and posted strong gains in 2014. Today I'm looking at the best two of that bunch: Buffalo Wild Wings (BWLD) and Chipotle Mexican Grill (CMG 0.74%). Both stocks roughly doubled the S&P 500's 13%-plus gain over the year.

CMG Chart

CMG data by YCharts.

Buffalo Wild Wings
Buffalo Wild Wings shares added to their 100% gain in 2013 by trouncing the market again this past year. Powering that stock growth has been a huge spike in profit: earnings through the first three quarters of the year leaped 44% to $3.90 from the prior year's $2.70 per share. 

Sure, B-Dubs achieved that stellar result with an assist from falling chicken wing costs, which is outside management's control. But CEO Sally Smith and her team also notched some important strategic wins in 2014. Chief among these has been improving the customer experience through a new position called "guest experience captain." Here's how Smith recently described the positive impact of this new role:

Captains are essential to engaging with our guests, making them feel welcome and customizing their experience, ensuring that Buffalo Wild Wings is their first choice for sports and entertainment. Captains help promote the new technology in our restaurants which we believe encourages guests to stay longer, visit more frequently and order more. In addition, Captains actively engage in their communities with local store marketing efforts.

Despite the added labor costs, the new position is clearly paying off. Comparable-store sales were up by a solid 7%, 8%, and 6% in the first three quarters of the year, respectively, which means guests are finding plenty of reasons to keep filling B-Dubs' booths during their favorite sporting event. That popularity should translate into continued earnings growth in the year ahead: analysts expect Buffalo Wild Wings to post an 18% profit gain in 2015. 

Chipotle Mexican Grill
Chipotle's 2014 run can be pegged on just one thing: outstanding revenue growth. The burrito slinger managed double-digit comparable-store sales gains all year, with the first and second quarters clocking in respectively at 13% and 17%. McDonald's, by comparison, reported negative comps over that period.

But even those gains look small in comparison to Chipotle's scorching 20% improvement in the third quarter -- its best comp result since going public in 2006. Tack on opening 43 new restaurants in the quarter, and that gets you to the company's extraordinary 31% overall sales growth.

Management credits Chipotle's commitment to its food as the key to those impressive gains. Diners are bolting from traditional fast food and toward higher-quality quick-service establishments that can deliver a better dining experience.

That trend is particularly pronounced with the younger generation, as CEO Steve Ells noted in a recent conference call with investors. "Millennials are more concerned with how food is raised and prepared than previous generations and are willing to seek out and pay a little more for something they recognize as better: better tasting, better for the environment, and better for their wellbeing," he said. 

Perhaps the best news for Chipotle and B-Dubs investors, though, is that both companies managed customer traffic gains in 2014 despite having boosted menu prices significantly. While that has provided an immediate benefit in higher comparable-store sales, it points to even greater gains down the line. With their customers happily paying a bit more for the experience, it's clear these restaurant operators are delivering value to their guests over and above what they are charging.