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::Eml->new(shift);
42 PublicInbox::View::multipart_text_as_html($mime, $ctx);
47 my $t = timeit(1, sub {
48 $ctx->{obuf} = \$obuf;
49 $ctx->{mhref} = '../';
51 ($oid, $type) = split / /;
52 next if $type ne 'blob';
54 $git->cat_async($oid, $cb);
58 diag 'multipart_text_as_html took '.timestr($t)." for $n <=> $m messages";
59 is($m, $n, 'rendered all messages');