Since 1968, only Jimmy Connors (109), Ivan Lendl (94) and John McEnroe (77) have won more singles tournaments than Federer and Sampras.
"It's amazing that I'm there where Pete's ended his career on," Federer said. "You never know when it's your last one. That's why you want to savor every tournament victory."
In beating the 47th-ranked Mayer at Royal Tennis Hall, Federer won his third title of the year. The unseeded German broke serve in the seventh game before Federer started spraying winners to take the set.
Federer showed glimpses of his best form in the second set, mixing power and finesse and ending the match in 63 minutes.
Federer, a 16-time Grand Slam winner, won his 50th match of the year Friday. He became only the fifth man, and the first since Sampras, to win 50 matches in at least nine straight years in the Open era.
"Early on, I think that feeling of wanting to prove yourself to the world and all the doubters is a very strong one, so you're very aggressive in your ways of winning and not enjoying them," Federer said. "Today it's much more of the enjoyment part because I don't need to prove myself to anyone anymore, except to myself."
Sweden's Crown Princess Victoria presented the trophy to Federer, who was appearing at this tournament for the first time in a decade.
"For me, every tournament victory is special," the Swiss star said. "This is one I'll definitely remember, maybe more than other ones."
Mayer, yet to win an ATP title, was appearing in his third career final and first in four years. He knocked out second-seeded Robin Soderling in the quarterfinals and his unorthodox style also gave Federer difficulty.
Federer has beaten Mayer in all three of their matches without losing a set. Indeed, Federer has lost only five matches against players ranked above 40 in the past five years.
"It was over really after the first set," Mayer said. "I got tired while his game improved a lot, but I felt it was a closer match than the score showed."
Federer had to come from a set behind to beat countryman Stanislas Wawrinka in the quarterfinals and was broken in the third game of Saturday's semifinal against fourth-seeded Ivan Ljubicic before coming back.
This was Federer's first tournament title in Sweden and the 18th country in which he has won.
"It feels great winning any tournament, but especially in a country where I've never been successful before," Federer said. "Mayer played a really good match in the final, and I had to really come up with some good tennis."