Last active
December 18, 2019 18:02
-
-
Save Songmu/3867745ee894785b71f4c7eea11a7803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.014; | |
use warnings; | |
use utf8; | |
use autodie; | |
use Time::HiRes qw/gettimeofday tv_interval/; | |
# you need `ghg` command to work it | |
my $workdir = '.tmp'; | |
my $trial = 100; | |
my @vers = reverse qw/ | |
v0.14.2 | |
v0.14.1 | |
v0.14.0 | |
v0.13.1 | |
v0.13.0 | |
v0.12.9 | |
v0.12.8 | |
v0.12.6 | |
v0.12.5 | |
v0.12.4 | |
v0.12.3 | |
v0.12.2 | |
v0.12.1 | |
v0.12.0 | |
v0.11.2 | |
v0.11.1 | |
v0.11.0 | |
v0.10.2 | |
v0.10.1 | |
v0.10.0 | |
v0.9.0 | |
v0.8.0 | |
/; | |
$ENV{GHG_HOME} = $workdir; | |
sub logf { | |
my $msg = sprintf(shift, @_); | |
$msg .= "\n" if $msg !~ /\n\z/ms; | |
print STDERR $msg; | |
} | |
for my $ver (@vers) { | |
my $bin = "$workdir/bin/ghq-$ver"; | |
next if -f $bin; | |
logf 'installing ghq %s', $ver; | |
my $cmd = "ghg get -u motemen/ghq\@$ver"; | |
`$cmd > /dev/null 2>&1`; | |
rename "$workdir/bin/ghq", $bin; | |
} | |
my $VCS_GIT = '-vcs=git'; | |
logf 'starting benchmark'; | |
chomp(my $repos = `$workdir/bin/ghq-v0.14.2 list | wc -l`); | |
logf '%d repositories on local', $repos; | |
my %results; | |
for my $i (1..$trial) { | |
logf 'trial: %d', $i; | |
for my $ver (@vers) { | |
my $bin = "$workdir/bin/ghq-$ver"; | |
for my $opt ('', $VCS_GIT) { | |
if ($opt eq $VCS_GIT) { | |
if ($ver !~ /^v0\.1/ || $ver lt 'v0.11.1') { | |
next; | |
} | |
} | |
my $t = [gettimeofday]; | |
`$bin list $opt > /dev/null`; | |
my $elapsed = tv_interval $t; | |
if ($? > 0) { | |
die 'error occurred on version: '. $ver; | |
} | |
$results{$ver . $opt} += $elapsed; | |
} | |
} | |
} | |
for my $ver (@vers) { | |
my $val = $results{$ver}; | |
printf "%s: %0.5f\n", $ver, ($val/$trial); | |
my $ver_with_git = $ver . $VCS_GIT; | |
if (my $val = $results{$ver_with_git}) { | |
printf "%s: %0.5f\n", $ver_with_git, ($val/$trial); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v0.8.0: 0.11212
v0.9.0: 0.15968
v0.10.0: 0.14563
v0.10.1: 0.14683
v0.10.2: 0.14698
v0.11.0: 0.19084
v0.11.1: 0.16911
v0.11.1-vcs=git: 0.16772
v0.11.2: 0.16753
v0.11.2-vcs=git: 0.16848
v0.12.0: 0.16859
v0.12.0-vcs=git: 0.16974
v0.12.1: 0.16861
v0.12.1-vcs=git: 0.16902
v0.12.2: 0.16753
v0.12.2-vcs=git: 0.16822
v0.12.3: 0.16832
v0.12.3-vcs=git: 0.16926
v0.12.4: 0.17000
v0.12.4-vcs=git: 0.16976
v0.12.5: 0.17013
v0.12.5-vcs=git: 0.16907
v0.12.6: 0.16950
v0.12.6-vcs=git: 0.16919
v0.12.8: 0.09405
v0.12.8-vcs=git: 0.09457
v0.12.9: 0.09557
v0.12.9-vcs=git: 0.09529
v0.13.0: 0.09531
v0.13.0-vcs=git: 0.09547
v0.13.1: 0.09611
v0.13.1-vcs=git: 0.11594
v0.14.0: 0.08618
v0.14.0-vcs=git: 0.10492
v0.14.1: 0.08328
v0.14.1-vcs=git: 0.11814
v0.14.2: 0.07938
v0.14.2-vcs=git: 0.12020
v0.15.0: 0.07899
v0.15.0-vcs=git: 0.11862