I am currently working on some refactoring of a large application under Git version control.
I wish to be able to benchmark my modified functions between my master branch and my unstable branch.
Currently I am thinking of doing a simple script like :
use Benchmark qw(:all) ;
use my_module ;
$count = -10
# Checkout my master code
system qw(git checkout <my_currently_in_production_version>) ;
timethis($count, sub {my_function()});
# Checkout my unstable code
system qw(git checkout <my_currently_unstable_version>) ;
something_to_reload_my_module();
timethis($count, sub {my_function()});
But it feels kind of hackish to me. Is there any cleaner solution to benchmark functions between Git branches?
Thanks for any help
Edit: I am mainly looking for something like the Benchmark module, but with support of branch changing, if it exist.
Well, you will need to checkout each version, but I wouldn’t try to “unload” anything. That’s just asking for trouble. That means two Perl interpreters need to be run: one for the old code and one for the new code.
What I would do is write a script that does the appropriate timings and saves the results to a file. Run it on both checkouts. Have a second script compare the results.
(The first four lines could be done by
compare_timesviasystem.)