2 # Copyright (C) all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
7 use Benchmark qw(:all);
8 use PublicInbox::Inbox;
10 use PublicInbox::Spawn qw(popen_rd);
12 my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
13 my $blob = $ENV{TEST_BLOB};
14 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
16 my @cat = qw(cat-file --buffer --batch-check --batch-all-objects);
17 if (require_git(2.19, 1)) {
18 push @cat, '--unordered';
21 "git <2.19, cat-file lacks --unordered, locality suffers\n";
23 require_mods qw(Plack::Util);
24 my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir, name => 'name' });
26 my $fh = $blob ? undef : $git->popen(@cat);
29 vec($vec, fileno($fh), 1) = 1;
30 select($vec, undef, undef, 60) or
31 die "timed out waiting for --batch-check";
35 env => { HTTP_HOST => 'example.com', 'psgi.url_scheme' => 'https' },
37 www => Plack::Util::inline_object(style => sub {''}),
39 my ($mime, $res, $oid, $type);
45 $mime = PublicInbox::Eml->new(shift);
46 PublicInbox::View::multipart_text_as_html($mime, $ctx);
51 my $t = timeit(1, sub {
52 $ctx->{obuf} = \$obuf;
53 $ctx->{mhref} = '../';
55 my $nr = $ENV{NR} // 10000;
58 $git->cat_async($blob, $cb);
62 ($oid, $type) = split / /;
63 next if $type ne 'blob';
65 $git->cat_async($oid, $cb);
70 diag 'multipart_text_as_html took '.timestr($t)." for $n <=> $m messages";
71 is($m, $n, 'rendered all messages');