With a total of five gold medals, Ryan Lochte beat fellow U.S. star Michael Phelps, who won four golds, two silvers and a bronze, in two head-to-head races and won by huge margins in every other event in which he competed. (PETER PARKS/AFP/GETTY IMAGES)

What wasn’t to like for Team USA on Sunday? Gold medals rained. Joy and relief intermingled. Tiny American flags danced throughout the Oriental Sports Center. Ryan Lochte earned his fifth world title on the last night of these eight-day championships. Three U.S. women collected medals and Michael Phelps helped the U.S. men’s 400 medley relay team to a come-from-behind victory.

With a final-day haul of four golds, one silver and one bronze, the U.S. team secured the overall and gold-medal counts. A little revelry would have been understandable, especially from Lochte, who concluded these championships as the undisputed star with another runaway gold-medal performance.

Yet Lochte sounded almost despondent as he assessed his week’s work after crushing the competition in the 400-meter individual medley, a race he won by more than four seconds.

“For the most part, I’m not really happy,” said Lochte, who touched the wall in 4 minutes 7.13 seconds — 3.29 seconds over Phelps’s world record. “I mean, getting five gold medals is definitely great, but the times I’ve went, I know I can go a lot faster. A lot of places in my races I messed up on. . . . I have a full year to make sure I have those perfect swims.”

Lochte’s performance here looked much better to just about everyone else. He beat Phelps, who won four golds, two silvers and a bronze, in two head-to-head races and won by huge margins in every other event in which he competed. His dominance ignited huge hopes for 2012 Olympics in London, but there were other promising sidebars. The team’s medal total of 29 and 16 golds surpassed its performance at the last world championships in Rome in 2009, when it captured 22 and 10.

“It was great beginning [Saturday] night and it just got greater tonight,” U.S. women’s team coach Jack Bauerle said. Sunday “was just sort of the topper. . . . This is unbelievably encouraging.”

If the men’s team looked well-armed with the multi-tasking Lochte and Phelps, who have both tried to downplay their growing rivalry, the women’s side displayed impressive depth. The night’s biggest stunner, though, came from China’s Sun Yang, 19, who broke the world record in the men’s 1,500, the only mark that did not fall before speedsuits were banned two years ago. Sun finished in 14:34.14, knocking .42 off of Grant Hackett’s 10-year-old record.

For the United States, Jessica Hardy and Elizabeth Beisel won individual golds in the 50 breast and 400 individual medley, respectively. Rebecca Soni claimed a bronze in the 50 breast to add to her three golds. Two years after winning just two golds at the world championships in Rome, the U.S. women got three from newcomer Missy Franklin, 16, and took home eight.

“The performances were terrific across the board,” Bauerle said.

That was not the case among the men, where Lochte and Phelps won all but three of the individual U.S. men’s medals. Tyler Clary won two, including the silver in Sunday’s 400 individual medley.

Lochte, who won golds in the 200 and 400 individual medleys, 200 freestyle, 200 backstroke and 4x200 free relay and a bronze in the 4x100 freestyle, insisted that he hadn’t taken over as “top dog,” but others saw it differently

“He hasn’t just been exceptional this year, he’s been exceptional the last five,” said Clary. “Unfortunately, he’s been hugely overshadowed by what Michael was doing. If Michael hadn’t existed, Ryan would be Michael. . . . I think here he wasn’t going to let anybody beat him at any cost.”

Phelps got his final gold with a flourish, helping Nick Thoman, Mark Gangloff and Nathan Adrian win the 4x100 medley relay. U.S. men’s coach Eddie Reese admitted he pondered putting Lochte on the backstroke leg even though he didn’t swim in the 100 back at this meet, but worried he would be tired after the 400 medley final. The move nearly backfired; Thoman led off in third place.

By the time Phelps entered the water for the butterfly leg, the Americans had fallen to fourth. Phelps, though, climbed to second with a swim of 50.57 seconds, and Adrian produced a time of 47. 64 on the anchor to overtake Japan’s Shogo Hihara while holding off a late-charging James Magnussen of Australia.

“I’ve been able to gather more motivation here than I already had,” Phelps said. “I think that’s something that will help me get into better shape for next year. . . . Ryan is clearly working hard and clearly in the best shape he’s probably ever been, and that’s why he is where he is.”

What remains to be seen is where everyone will be next year.

“We’ve got people coming,” Reese said. “The Olympic trials, I think it’s going to be the best meet any of us have ever seen.”