1 # Copyright (C) 2019-2020 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 use PublicInbox::TestCommon;
11 my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
12 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
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";
21 require_mods qw(Plack::Util);
23 my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir, 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 ($mime, $res, $oid, $type);
41 $mime = PublicInbox::MIME->new(shift);
42 PublicInbox::View::multipart_text_as_html($mime, $ctx);
47 $git->cat_async_begin;
48 my $t = timeit(1, sub {
49 $ctx->{obuf} = \$obuf;
50 $ctx->{mhref} = '../';
52 ($oid, $type) = split / /;
53 next if $type ne 'blob';
55 $git->cat_async($oid, $cb);
59 diag 'multipart_text_as_html took '.timestr($t)." for $n <=> $m messages";
60 is($m, $n, 'rendered all messages');