0

我目前正在对 Git 版本控制下的大型应用程序进行一些重构。我希望能够在我的主分支和我的不稳定分支之间对我修改过的函数进行基准测试。

目前我正在考虑做一个简单的脚本,如:

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()});

但这对我来说有点骇人听闻。Git 分支之间的基准函数是否有更清洁的解决方案?

谢谢你的帮助

编辑:我主要是在寻找像 Benchmark 模块这样的东西,但如果它存在,它支持分支更改。

4

1 回答 1

2

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.

git checkout stable
../tools/time_test > stable
git checkout unstable
../tools/time_test > unstable
compare_times stable unstable

(The first four lines could be done by compare_times via system.)

于 2012-05-29T16:58:40.953 回答