It's no secret that staying up all night is terrible for your body. Without sleep, your brain can’t consolidate memories, which makes recalling new information difficult. It doesn’t help that your thoughts are, quite literally, dirty. Throughout the day, toxic proteins and metabolites accumulate in your noggin, and it needs sleep to flush them out. But if you must pull an all-nighter, you’ve got two options: Prepare with a nap, or drench your system in caffeine.

In 2008, researchers at UC San Diego put naps and caffeine to the test. One morning, they gave 61 people a battery of memory and motor skills tests. Then half of the group took about a 90-minute nap. The others spent their downtime listening to a book on tape and, at the end, swallowed a caffeine pill (or a placebo). The researchers woke the nappers and tested all of the participants again. The caffeine group reported feeling the most alert, but they didn’t act like it: The nappers netted better scores.

The conclusion? Caffeine will keep you awake, but it’s no substitute for the restorative powers of sleep. A 90-minute prophylactic nap—that is, a snooze specifically intended to prep you for an all-nighter—can carry you for about eight to 10 hours. (Meanwhile, 200mg of coffee will keep you going for six—and then you’ll crash.) In fact, a NASA study found that while a 15-minute nap might not make you feel physically better, it still boosts cognitive performance. And a 25-minute nap made pilots 35 percent more alert and twice as focused. Makes you wonder what happens when you dream of lattes.