UAHoliday1_2016_Phelps_Pool_Underwater_0445
U.S. swimmer Michael Phelps won six medals, including five golds, at the Rio Summer Olympics. Courtesy of Under Armour

How Tracking Sleep and Diet Helped Michael Phelps in Rio

Aug 31, 2016

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.

Michael Phelps and his team used MyFitnessPal to track the athlete's food intake.Michael Phelps and his team tracked his food intake using Courtesy of Under Armour 

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.

All products and services featured are based solely on editorial selection. FORTUNE may receive compensation for some links to products and services on this website.

Quotes delayed at least 15 minutes. Market data provided by Interactive Data. ETF and Mutual Fund data provided by Morningstar, Inc. Dow Jones Terms & Conditions: http://www.djindexes.com/mdsidx/html/tandc/indexestandcs.html. S&P Index data is the property of Chicago Mercantile Exchange Inc. and its licensors. All rights reserved. Terms & Conditions. Powered and implemented by Interactive Data Managed Solutions