2 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
6 use PublicInbox::TestCommon;
8 use PublicInbox::Inbox;
9 use List::Util qw(max);
10 use Benchmark qw(:all :hireswallclock);
11 use PublicInbox::Spawn qw(popen_rd);
13 require_git(2.19); # for --unordered
14 my $inboxdir = $ENV{GIANT_INBOX_DIR};
15 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
16 my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir, name => 'x' });
18 my @cat = qw(cat-file --buffer --batch-check --batch-all-objects --unordered);
19 my $fh = $git->popen(@cat);
21 my ($bref, $oid, $type, $size, $check) = @_;
23 my $copy = PublicInbox::Eml->new($bref)->as_string;
24 ++$check->[$orig eq $copy ? 0 : 1];
28 my $check = [ 0, 0 ]; # [ eql, neq ]
29 my $t = timeit(1, sub {
32 ($blob, $type) = split / /;
33 next if $type ne 'blob';
34 $git->cat_async($blob, $cat_cb, $check);
35 if ((++$n % 8192) == 0) {
36 diag "n=$n eql=$check->[0] neq=$check->[1]";
41 is($check->[0], $n, 'all messages round tripped');
42 is($check->[1], 0, 'no messages failed to round trip');