Sleepy drivers who don’t want to stop their journey have two choices: pull over and take a short nap or load up with caffeine to stay awake.

So what’s the better option? French researchers decided to find out, testing the driving performance of two dozen sleep-deprived motorists. Participants first drove a two-mile course on the highway between 6 p.m. and 7:30 p.m., to measure their driving skill on a normal amount of sleep. On other days, they were asked to take the driving test again between 2 a.m. and 3:30 a.m. They were given either a placebo (decaffeinated coffee), regular coffee or allowed to take a 30-minute nap, according to the study, published this month in the medical journal Sleep.

A driving instructor in the car counted the number of inappropriate line crossings during each driving test. Line crossings were measured because drifting over the center line or off the road causes 65 percent of sleep-related accidents.

The decaf drinkers racked up a total of 159 line crossings while drowsy, compared to just 2 line crossings during the daytime driving test. Nappers did better, crossing lines only 84 times. But surprisingly, the coffee drinkers did the best in the sleepy driving test, crossing lines a total of 27 times.

But what was surprising is that the effect of coffee and napping varied by age. For middle-aged drivers, aged 40 to 50, coffee was a far better choice. Caffeinated coffee lowered risk for these drivers by 89 percent, while the nap only reduced line crossings by 23 percent. But among younger drivers, a nap was almost as effective as caffeine. Among 20- to 25-year-old drivers, the risk of line-crossing fell by 66 percent after a nap, and 74 percent after drinking caffeinated coffee.

The authors noted that the effects of caffeine on driving performance weren’t altered by age, but that the younger drivers slept longer and more deeply than middle-aged drivers during the half-hour nap, and appeared to experience more restorative benefits of sleep.

While the study shows that caffeinated coffee is a better option than napping for drowsy drivers, the better choice is to get off the road entirely and get a full night’s sleep.