In the beginning, Ryan Lochte swam at Michael Phelps’s hip and drafted off his fame. He signed with the same sports agency and the same swimwear company, and he smiled like a rakish groomsman after Phelps beat him at the 2008 Olympics in the 200- and 400-meter individual medleys.

From his perch on the deck in Beijing, Lochte observed Phelps racing as if wearing blinders on his way to a record eight gold medals, and Lochte’s mirth hardened into mettle. He realized it was not physical or mental strength that separated them; it was strength of purpose.

If Lochte was going to move out of Phelps’s slipstream, he would have to train smarter, eat healthier, lift more. He added strongman exercises to his dryland routine, grilled chicken breasts to his diet and two marketing mavericks to his inner circle. Out went greasy foods, sugary beverages and the Octagon representation that he shared with Phelps.

In the lead-up to the 2012 Olympics, Lochte, who turns 28 on Aug. 3, has been more focused at the pool, if no less flighty away from it. He has retained the skateboard, the sketchpad, the rococo wardrobe and the appetite for high jinks that call to mind a character in a Judd Apatow movie. His grand plan, executed so far without a glitch, is to roll out a more user-friendly version of Phelps in London.