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::WwwStream;
12 my $inboxdir = $ENV{GIANT_INBOX_DIR};
13 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
15 my $obfuscate = $ENV{PI_OBFUSCATE} ? 1 : 0;
16 diag "obfuscate=$obfuscate\n";
18 my @cat = qw(cat-file --buffer --batch-check --batch-all-objects);
19 if (require_git(2.19, 1)) {
20 push @cat, '--unordered';
23 "git <2.19, cat-file lacks --unordered, locality suffers\n";
25 require_mods qw(Plack::Util);
26 my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir, name => 'name' ,
27 obfuscate => $obfuscate});
29 my $fh = $git->popen(@cat);
31 vec($vec, fileno($fh), 1) = 1;
32 select($vec, undef, undef, 60) or 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 {''}),
38 gz => PublicInbox::GzipFilter::gzip_or_die(),
39 }, 'PublicInbox::WwwStream';
40 my ($eml, $res, $oid, $type);
44 $ctx->{mhref} = '../';
47 $eml = PublicInbox::Eml->new(shift);
48 $eml->each_part(\&PublicInbox::View::add_text_body, $ctx, 1);
55 my $t = timeit(1, sub {
57 ($oid, $type) = split / /;
58 next if $type ne 'blob';
60 $git->cat_async($oid, $cb);
64 diag 'add_text_body took '.timestr($t)." for $n <=> $m messages";
65 is($m, $n, 'rendered all messages');