1 # Copyright (C) 2019 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use Benchmark qw(:all);
7 use PublicInbox::Inbox;
9 require './t/common.perl';
11 my $pi_dir = $ENV{GIANT_PI_DIR};
12 plan skip_all => "GIANT_PI_DIR not defined for $0" unless $pi_dir;
14 my @cat = qw(cat-file --buffer --batch-check --batch-all-objects);
15 if (require_git(2.19, 1)) {
16 push @cat, '--unordered';
19 "git <2.19, cat-file lacks --unordered, locality suffers\n";
23 my $ibx = PublicInbox::Inbox->new({ mainrepo => $pi_dir, name => 'name' });
25 my $fh = $git->popen(@cat);
27 vec($vec, fileno($fh), 1) = 1;
28 select($vec, undef, undef, 60) or die "timed out waiting for --batch-check";
31 env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'https' },
33 www => Plack::Util::inline_object(style => sub {''}),
35 my ($str, $mime, $res, $cmt, $type);
37 my $t = timeit(1, sub {
39 ($cmt, $type) = split / /;
40 next if $type ne 'blob';
42 $str = $git->cat_file($cmt);
43 $mime = PublicInbox::MIME->new($str);
44 $res = PublicInbox::View::msg_html($ctx, $mime);
46 while (defined($res->getline)) {}
50 diag 'msg_html took '.timestr($t)." for $n messages";