]> Sergey Matveev's repositories - public-inbox.git/blob - t/thread-all.t
d4e8c1fcda5ac8aee2fd52ead56adad78df95bd4
[public-inbox.git] / t / thread-all.t
1 # Copyright (C) 2016-2018 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 Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
9 my $pi_dir = $ENV{GIANT_PI_DIR};
10 plan skip_all => "GIANT_PI_DIR not defined for $0" unless $pi_dir;
11 eval { require PublicInbox::Search; };
12 plan skip_all => "Xapian missing for $0" if $@;
13 my $srch = eval { PublicInbox::Search->new($pi_dir) };
14 plan skip_all => "$pi_dir not initialized for $0" if $@;
15
16 require PublicInbox::View;
17 require PublicInbox::SearchThread;
18
19 my $pfx = PublicInbox::Search::xpfx('thread');
20 my $opts = { limit => 1000000, asc => 1 };
21 my $t0 = clock_gettime(CLOCK_MONOTONIC);
22 my $elapsed;
23
24 my $sres = $srch->_do_enquire(undef, $opts);
25 $elapsed = clock_gettime(CLOCK_MONOTONIC) - $t0;
26 diag "enquire: $elapsed";
27
28 $t0 = clock_gettime(CLOCK_MONOTONIC);
29 my $msgs = PublicInbox::View::load_results($srch, $sres);
30 $elapsed = clock_gettime(CLOCK_MONOTONIC) - $t0;
31 diag "load_results $elapsed";
32
33 $t0 = clock_gettime(CLOCK_MONOTONIC);
34 PublicInbox::View::thread_results($msgs);
35 $elapsed = clock_gettime(CLOCK_MONOTONIC) - $t0;
36 diag "thread_results $elapsed";
37
38 done_testing();