I have a function calc to optimize. Say the old version as base and the new version as opt. There are 3 ways I can figure out to compare the performance in function/instruction level of pprof.
- use
//go:build optandgo test -tags=tagA -bench BenchmarkXXX -run none -cpuprofile -o opt.outforoptand//go:build !optandgo test -bench BenchmarkXXX -run none -cpuprofile -o base.outforbase. Then usego tool pprof -base base.out opt.outto compare these two versions. But since code are built with different tags and the function definitions ofcalcare in two files, pprof can’t actually comparecalcas follows:
- use git history. One commit for
baseand one commit foropt,calcis implemented in one file. Butgit resetmight not be convenient I think? - use two copy of repositories, one for
baseand one foropt. But file paths ofbaseandoptare different. As approach 1, pprof won’t compare these two versions ofcalcin different files.
Are there some other ways to compare the two different versions of calc?
