Michael Phelps spent countless hours in the pool as he geared up for his fifth appearance in the Olympic Games this summer in Rio. But to help get back to his peak form, the swimming legend got some help from the suite of fitness technology by his sponsor Under Armour (ua).
Under Armour shared with Fortune some key data that it helped collect for Phelps as he geared up for Rio. One interesting finding: in the 373 nights leading up the Rio Olympics, Phelps averaged seven hours and 36 minutes of sleep. He aimed to get as close to that target as possible while in Rio as well.
The world’s greatest swimmer only began to consider sleep as an important component of his training back in early 2015, after exiting a rehab program he had entered in the wake of a DUI arrest. At that time, Phelps had a big decision to make: did he want to aim for the Rio Olympics by focusing just on winning slots on relay teams, or did he want to achieve more?
“When we first had a sleep monitoring system available to us, Michael was skeptical,” says Phelps’ trainer Keenan Robinson in an interview with Fortune. “We know sleep is important but until recently, the way to pull objective measures and apply to sports training has been limited.”
Robinson admits that while Phelps’ compliance at times was “hit and miss,” they saw results. Monitoring sleep helped in training and ultimately was part of why Phelps swam so strongly at the 2015 national meet in San Antonio. “What it helped us do is set up a weekly training schedule more appropriately,” says Robinson, explaining that by tracking sleep, Phelps could more accurately predict how capable he would be to perform certain workouts in the pool.
All of this data collection may seem a bit wonky to casual athletes. But Baltimore-based Under Armour, the second-largest U.S. athletic-gear maker after Nike (nke), is envisioning a world where professional and casual athletes can track their movements, workouts, sleep, and other metrics. The ultimate goal? Help those athletes perform better on the track, while out biking, or in the case of Phelps—swim more swiftly in the pool.
Under Armour’s connected fitness platform, which contains a mix of apps, fitness tracking bands, and other “smart” devices, carefully monitors four quadrants: sleep, fitness, activity, and nutrition. The idea is the more closely an athlete monitors those components, the greater success they’ll have achieving their fitness goals if they are able to determine optimal diet and sleep patterns.
It is also a compelling new component of Under Armour’s business. Revenue from “connected fitness” hit $42 million in the first half of 2016, up 91% from a year ago. Still greatly dwarfed by sales of Under Armour shirts and shoes, the company sees investments in tech as a way to compete more aggressively in the athletic wear space in the future. It believes younger athletes want more data.
Interestingly, sleep is an element of fitness preparation that still isn’t fully understood, but seems critical. When Fortune wrote about golfer Jordan Spieth’s own experimentation with connected gear by Under Armour earlier this year, he also explained that sleep monitoring was very important. (Spieth prefers at least eight hours of sleep each night).
“No two people are the same,” says Robinson. He contends that pro athletes have only really began to track sleep using technology over the past seven years or so. “By the time of the Tokyo Olympics, technology is going to help specific training plans for coaches about how the body responds to certain levels of sleep and nutrition and how it helps or hinders your performance.”
Phelps’ close work with Under Armour also led him to use the company’s MyFitnessPal as a way to track his nutrition. Robinson says that helped the star swimmer compete at his highest level as he geared up for Rio. For example, at a certain weight or with a certain calorie intake, Phelps and his team could determine what training plans were achievable.
“If I had to put together a list of the top five apps for sports performance, [MyFitnessPal] would be in there,” Robinson says. The strength and conditioning coach says using the app made it easy to see when there were shortcomings in Phelps’ caloric intake. “It isn’t a wild goose chase to figure out where you fell short.”
No athletic training regime is perfect and when it comes to piling on the pounds ahead of Rio, Phelps didn’t hit his mark. He aimed to get to 205 pounds before the Games (as Phelps would almost certainly lose weight throughout the competition). But he ended up only hitting 196 pounds. By logging his food intake closely, it became clear to Phelps’ team that there was nothing more they could do to add more weight.
That provided some comfort to both Phelps and Robinson, it ultimately didn’t hinder his performance in Rio. Phelps still won six medals—including five golds.