Skip to content

Instantly share code, notes, and snippets.

@Songmu
Last active December 18, 2019 18:02
Show Gist options
  • Save Songmu/3867745ee894785b71f4c7eea11a7803 to your computer and use it in GitHub Desktop.
Save Songmu/3867745ee894785b71f4c7eea11a7803 to your computer and use it in GitHub Desktop.
#!/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);
}
}
@Songmu
Copy link
Author

Songmu commented Dec 18, 2019

868 repositories on local
v0.8.0: 0.03433
v0.9.0: 0.07397
v0.10.0: 0.07765
v0.10.1: 0.07701
v0.10.2: 0.07757
v0.11.0: 0.08700
v0.11.1: 0.08929
v0.11.1-vcs=git: 0.08974
v0.11.2: 0.09140
v0.11.2-vcs=git: 0.09050
v0.12.0: 0.08982
v0.12.0-vcs=git: 0.09041
v0.12.1: 0.08845
v0.12.1-vcs=git: 0.08808
v0.12.2: 0.08812
v0.12.2-vcs=git: 0.09060
v0.12.3: 0.08907
v0.12.3-vcs=git: 0.08915
v0.12.4: 0.08874
v0.12.4-vcs=git: 0.08831
v0.12.5: 0.08957
v0.12.5-vcs=git: 0.08954
v0.12.6: 0.08884
v0.12.6-vcs=git: 0.08823
v0.12.8: 0.03426
v0.12.8-vcs=git: 0.03365
v0.12.9: 0.03527
v0.12.9-vcs=git: 0.03467
v0.13.0: 0.03578
v0.13.0-vcs=git: 0.03531
v0.13.1: 0.03619
v0.13.1-vcs=git: 0.02917
v0.14.0: 0.03199
v0.14.0-vcs=git: 0.02689
v0.14.1: 0.03097
v0.14.1-vcs=git: 0.02732
v0.14.2: 0.02998
v0.14.2-vcs=git: 0.02963

@Songmu
Copy link
Author

Songmu commented Dec 18, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment