Animals sleep in all sorts of different ways. We are most familiar with the idea that sleep is a passive state, when an animal doesn't move much and its muscles relax, but that's not a hard-and-fast rule: some dozing birds can even fly, by sleeping with only half their brain.

"Sleep is a way animals become more efficient," says Dr Jerome Siegel, director of the Center for Sleep Research at UCLA in California, US.

Some animals sleep far more than others, and Siegel says that is largely down to how much time they spend eating. "Animals that eat food with low calorific density sleep less, although sleep can adjust to animals' needs."

On the whole, herbivores are said to sleep for less time than carnivores, because they need to spend more time munching to gain enough energy from their food. That is especially true for big grazers like giraffes. In the 1970s, scientists observed that giraffes in the wild only entered deep sleep for 5 to 30 minutes a day.

That sleeplessness could also be a defence mechanism. "Reduced sleep in more vulnerable animals may be adaptive to increase their vigilance for predators," says Dr John Lesku from La Trobe University in Melbourne, Australia.

Animals that don't make the right 'decision' are less likely to pass their genes on

Conversely, predators can presumably spend less time watching their backs, especially in social groups. Lions are famed for their habit of lying around for much of the day. In captivity they are known to sleep for 10 to 15 hours a day.

But rather than having one big session, lions are "cathemeral", meaning they sleep opportunistically for short spells. According to Siegel, this is so they don't miss out on a meal.

"A hungry animal needs to sleep less if there is food available, and more if there is no food available," he says.  "Animals that don't make the right 'decision' are less likely to pass their genes on."

It's worth bearing in mind that few scientists have volunteered to stay up all night to watch sleeping lions, presumably in case the lions wake up. In fact, being able to find wild animals in the first place is one of the biggest obstacles to understanding their sleep patterns.

For example, giant armadillos make it on to lists of sleepy animals due to their habit of spending an average of 18 hours a day in their underground burrows. But there's no evidence that they spend all of this time catching forty winks.

According to a study of koala activity in Victoria, they actually sleep for around 14.5 hours

"Actually we suspect they also feed, as generally their burrow is near a termite mound and the sleeping chamber is often at the base of the termite mound," says Dr Arnaud Desbiez, co-ordinator of the Pantanal Giant Armadillo Project.

When we do manage to see what an animal is doing, posture is often key to discerning whether it is asleep.

For instance, giraffes rest their heads on their rumps. Elsewhere, koalas slump, and they are rumoured to only actually be awake for 2 hours a day.

According to a study of koala activity in Victoria, they actually sleep for around 14.5 hours and spend almost another 5 hours resting, as their diet of eucalyptus leaves takes effort to digest and only delivers low energy rewards.

My guess is that this was one compromised bat

In a 2013 study, wild koalas were fitted with accelerometers to measure their daily activity, but the devices were not sensitive enough to discern rest from sleep. The "gold standard" in identifying sleep is to measure the electrical impulses sent by the brain, using electroencephalography (EEG).

For this reason, the most detailed data on animal sleep comes from captive subjects. According to Lesku, the current record holders for sleep are the large hairy armadillo at 20.4 hours and the little pocket mouse at 20.1 hours.

But even these values need to be treated with caution. "These are wild animals brought into the novel laboratory environment and recorded in a new, potentially dangerous environment with food provided," says Lesku.

For instance, a little brown bat was studied in this way in 1969 and earned the animals a reputation for being the longest sleepers. It got 19.9 hours of shut eye in a 24-hour period.

When animals like bats go into torpor during periods of cold temperatures, we call it hibernation

But it was attached to a computer rather than hanging from its usual cave ceiling, and the temperatures were altered. "My guess is that this was one compromised bat and hardly representative of a wild animal," says Lesku.

In particular, it may not have been sleeping at all. Instead, it could have gone into a more extreme state called torpor.

Many animals can go into an energy-saving state called torpor. When animals like bats go into torpor during periods of cold temperatures, we call it hibernation. In high temperatures it is known as aestivation.

Some animals go into torpor every day. The American badger and elegant fat-tailed mouse possum can both clock up an average of 14 hours, according to a 2014 review.

Torpor is fundamentally different to sleep. It is a kind of dormancy: metabolic rate and body temperature both drop and brain activity is dramatically decreased, in order to conserve energy.

40% of the day is a remarkable amount of rest time

To test the true sleeping brain activity of animals in the wild, scientists started with the most renowned sleepers: sloths.

In captivity they are known to sleep for more than 15 hours, but in 2008 researchers found that wild sloths sleep far less. After fitting brown-throated sloths in Panama with small EEG recorders, they discovered the animals were sleeping for less than 10 hours. That's about the same as lions, and far less than koalas or any of the captive animals.

Still, 40% of the day is a remarkable amount of rest time, especially for an animal that only eats fruit and leaves, and can be prey for cats and eagles.

One possible explanation is that sloths have evolved to blend into their environment using exceptionally good camouflage – and deliberately subdued behaviour. If that's true, their sleepy reputation is unlikely to be disturbed, even though it isn't really fair.