A new study says there is a right time to drink coffee so it's most effective.

U.S. Army researchers created a computer algorithm that studies sleep patterns to make recommendations about coffee intake.

The scientists hope to incorporate the algorithm in a pre-existing online tool that people can use for personal recommendations.

If you love caffeine, you may think there's never a wrong time for coffee, but a new study says there is a right time to get the most out of your daily cup.

Researchers from the United States Army developed an algorithm that makes personal recommendations for timing your caffeine consumption, so you can drink the least amount of coffee to achieve the maximum level of alertness. They published their study in the May issue of the Journal of Sleep Research.



This content is imported from Giphy. You may be able to find the same content in another format, or you may be able to find more information, at their web site.

The study found that the algorithm helped people improve their alertness by up to 64 percent — without consuming any more caffeine than normal. On the flip side, it found that with the right dosing schedule, people could reduce their caffeine consumption by up to 65 percent and still achieve peak alertness.

"The algorithm hinges on our ability to accurately predict how an individual responds to sleep deprivation and how an individual responds to caffeine," study co-author Jaques Reifman, research scientist at the United States Military, explained to MensHealth.com.



To get to their findings, the researchers administered "alertness" tests that determined how quickly people completed certain tasks. Then, they fed the results to the algorithm, which predicted how sleep deprivation, schedule, and caffeine impacted alertness during different times of the day.

"Once it knows how you respond to sleep deprivation and caffeine, it [the algorithm] generates thousands of possible caffeine schedules."



Finally, a computer program compared the predictions until it found the people's peak levels of alertness.



Getty Images

Reifman says the algorithm was developed for army workers, but it will also be offered online for anyone to use. Eventually, the algorithm will be included into an already existing online tool, 2B-Alert. Currently, 2B-Alert predicts alertness based on how much caffine and sleep someone has had.

Unfortunately, there is no easy way to determine this on your own, Reifman says. However, the team is developing a smartphone app that identifies the amount of caffeine you already have in your system, how sleep deprived you are, and the time of day you’d like to be most alert is on the horizon.

As a real-world example, Reifman says that people could use the algorithm to figure out when they should drink coffee so they’re prepared for a big test, meeting or presentation.

Getty Images

Until the algorithm is widely available, there are other ways to up your alertness — like with exercise. A study from 2011 revealed that people who worked out for 150 minutes a week slept better and were less groggy during the day.

The right snack will also help increase your energy. Here are 8 surprising foods that'll give you a much-needed energy boost.

Melissa Matthews Health Writer Melissa Matthews is the Health Writer at Men's Health, covering the latest in food, nutrition, and health.

This content is created and maintained by a third party, and imported onto this page to help users provide their email addresses. You may be able to find more information about this and similar content at piano.io