"There must have been a home run derby I didn't know about," Bumgarner said.
Peralta's homer was his second this spring, one more than he has hit in 133 regular-season at-bats as a professional. He also homered last week against the Padres. Gomez's homer was his third this year. Martin Maldonado added another solo shot, off Giants reliever Javier Lopez, in the eighth.
On the mound, Peralta allowed one run on six hits in 6 1/3 innings, with no walks and five strikeouts. He is currently pegged to start the Brewers' fifth game of the regular season.
Bumgarner's next start will be the first of his career on Opening Day. He was charged with three earned runs on five hits in 5 2/3 innings, with no walks and six strikeouts. The left-hander will face the D-backs on Monday night at Chase Field.
Buster Posey and Michael Morse had two hits apiece for the Giants, with Morse's RBI single in the third inning giving Bumgarner a lead. Pablo Sandoval homered leading off the eighth inning to cut the Brewers' lead to 3-2, but a further Giants rally was scratched when Gregor Blanco, trying to stretch a single into a double, was thrown out by Brewers right fielder Ryan Braun.
The Giants tied the game with four straight hits off Wei-Chung Wang in the ninth, with Juan Perez and Gary Brown each driving in a run. Mark Minicozzi then hit a sacrifice fly to plate the go-ahead run.
Up next: In the club's Cactus League finale, manager Bruce Bochy is expected to use a lineup that duplicates the projected Opening Night contingent as closely as possible. Second baseman Marco Scutaro likely will remain sidelined with a bad back, but the other regulars should be in there against the Colorado Rockies. Matt Cain, who hasn't faced Major League competition since March 15, will make his fourth exhibition start. Cain allowed three runs in six innings against an Angels Triple-A affiliate last Friday, which followed a 2 2/3-inning, seven-run outing against Oakland. After the game, the Giants will head for San Francisco to begin the Bay Bridge Series on Thursday at AT&T Park.
Adam McCalvy is a reporter for MLB.com. Read his blog, Brew Beat, and follow him on Twitter at @AdamMcCalvy. This story was not subject to the approval of Major League Baseball or its clubs.