]> Sergey Matveev's repositories - public-inbox.git/blob - xt/perf-threading.t
57e9db9ba90cf5491757d83bcf3c7749aaa8a731
[public-inbox.git] / xt / perf-threading.t
1 # Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 #
4 # real-world testing of search threading
5 use strict;
6 use warnings;
7 use Test::More;
8 use Benchmark qw(:all);
9 use PublicInbox::Inbox;
10 my $inboxdir = $ENV{GIANT_INBOX_DIR} // $ENV{GIANT_PI_DIR};
11 plan skip_all => "GIANT_INBOX_DIR not defined for $0" unless $inboxdir;
12 my $ibx = PublicInbox::Inbox->new({ inboxdir => $inboxdir });
13 eval { require PublicInbox::Search };
14 my $srch = $ibx->search;
15 plan skip_all => "$inboxdir not configured for search $0 $@" unless $srch;
16
17 require PublicInbox::View;
18
19 my $msgs;
20 my $elapsed = timeit(1, sub {
21         $msgs = $ibx->over->recent({limit => 200000});
22 });
23 my $n = scalar(@$msgs);
24 ok($n, 'got some messages');
25 diag "enquire: ".timestr($elapsed)." for $n";
26
27 $elapsed = timeit(1, sub {
28         PublicInbox::View::thread_results({ibx => $ibx}, $msgs);
29 });
30 diag "thread_results ".timestr($elapsed);
31
32 done_testing();