In our quest for a good night’s sleep, most of us focus on the mattress. And that’s understandable — it’s expensive and we’re going to live with it for many years.

Just don’t overlook the pillow. All too often, pillows are an impulse purchase, something you grab when you see a sale.

You spend about a third of your life in bed, so your pillow should feel comfortable and give you the support you need.

For it’s first-ever pillow test, Consumer Reports rated 10 pillows from popular brands including Casper, Sealy, Tempur-Pedic and MyPillow. They ranged in price from about $4 (for one at Sam’s Club) to a top-of-the-line Tempur-Pedic that sells for $170. Consumer Reports' Haniya Rae says tests show that when it comes to pillows, you generally get what you pay for.

“Not every pillow at the bottom of our charts is inexpensive. But more often than not, the ones at Walmart or Target, that are like $10 for two pillows, don't last quite as well in our resilience test,” Rae told NBC News BETTER. “They flatten out very quickly and they tend not to fluff up afterwards. So, you're sort of throwing money down the drain if it's a pillow that you're going to sleep on all the time.”

HOW DO THEY TEST PILLOWS?

Consumer Reports considers both objective machine-based test results and subjective comments from people who lie on the pillows to see how they feel.

The critical factor for any pillow is how it supports the head and neck of people of all sizes when they sleep on their back or their side. That can make the difference between a good night’s sleep and a stiff neck, Rae said. A good pillow must also breathe and dissipate heat, so it doesn’t make you sweaty.

Consumer Reports uses a special environmental chamber to assess how well a pillow should hold up over time. The chamber is set at a 98.6 F (body temperature) and 80 percent humidity. Each pillow has a 225-pound load, evenly distributed, put on it. After 96 hours, the pillow is removed from the chamber and the thickness and firmness are measured. That’s done again after it’s hand-fluffed.

It takes about 200 hours to test each pillow. Readings are taken from a pressure mat, humidity and temperature sensors, and a material testing machine. The result: hundreds of data points for each pillow.

Get the better newsletter. This site is protected by recaptcha

AND THE WINNERS ARE…

Of the 10 pillows tested, Consumer Reports recommends three:

Coop Home Goods Premium Adjustable Loft ($60): The top-performing pillow, it scored 84 out of 100 and got excellent marks for side support, back support, resilience and user preference. You can remove some of the shredded memory foam and polyester fiberfill or add more (it comes with some extra) to adjust the firmness. Coop Home Goods offers a 100-night sleep satisfaction guarantee.

Tempur-Pedic Breeze Dual Cooling ($170): The most expensive pillow in the test, it came in second with an overall score of 72. Consumer Reports says the memory foam slab offers great support for side sleepers and maintains its shape very well. “But if you sleep warm, you may want to check out other options,” the editors noted. That’s because this pillow slowly retains heat, so it could make your head sweaty.

Sealy Memory Foam Gel ($65): Made from a single slab of foam, the Sealy (overall score of 71) holds its shape and is rated excellent for side sleepers. Like the Tempur-Pedic, Consumer Reports says it “grows warmer as you lie on it — trapping heat and moisture under your head.”

Other noteworthy results

MyPillow Premium ($80): This highly publicized pillow earned a score of 68. It’s made from shredded polyurethane foam that may keep your head cooler. But during the testing, the pieces of foam moved around and shifted out of place. “Some of our testers found sleeping on it to be annoying because the foam tended to bunch up around the head and neck,” the editors wrote.

MyPillow Classic ($40): It’s made with the same, but slightly less, shredded polyurethane foam as the MyPillow Premium. But with low marks for resilience and user preference, it‘s overall score was 58. Testers found that the foam “tended to bunch up,” making it harder for it to maintain its shape.

NBC News BETTER contacted MyPillow about these results. Mike Lindell, inventor and CEO of MyPillow, said in an emailed statement:

“I have never paid attention to media reviews and won’t start now. I have sold more than 46 million MyPillows and have millions of happy customers. They are my focus. I view every customer like it’s my only customer, and it’s their opinions that matter to me.”

Beckham Luxury Linens Hotel Collection ($35): With an overall rating of 67, Consumer Reports calls this a “bargain buy” for side and back sleepers.

Casper The Pillow ($65): Consumer Reports calls it an “average” pillow that will help you sleep cooler. Casper offers a 100-night sleep trial.

WHAT WILL WORK FOR YOU?

Clearly, pillows are subjective. But in general, a flatter pillow is better for a back sleeper and a fluffier pillow is better for side sleepers. Stomach sleepers want a flat pillow that doesn’t raise the head.

You might be able to determine this in the store by looking at the package. If not, do your best to feel it. See if it fluffs back up after you push it out of shape. Your best bet is to buy from a store or manufacturer that offers a money-back satisfaction guarantee. Consumer Reports’ Pillow Buying Guide explains what to look for when buying pillows, as well as how to care for the ones you bring home.

READY TO GET MORE ZZZ’S? READ THESE AND REST BETTER

Want more tips like these? NBC News BETTER is obsessed with finding easier, healthier and smarter ways to live. Sign up for our newsletter and follow us on Facebook, Twitter and Instagram.