1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 # real-world testing of search threading
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 $@;
16 require PublicInbox::View;
17 require PublicInbox::SearchThread;
19 my $pfx = PublicInbox::Search::xpfx('thread');
20 my $opts = { limit => 1000000, asc => 1 };
21 my $t0 = clock_gettime(CLOCK_MONOTONIC);
24 my $sres = $srch->_do_enquire(undef, $opts);
25 $elapsed = clock_gettime(CLOCK_MONOTONIC) - $t0;
26 diag "enquire: $elapsed";
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";
33 $t0 = clock_gettime(CLOCK_MONOTONIC);
34 PublicInbox::View::thread_results($msgs);
35 $elapsed = clock_gettime(CLOCK_MONOTONIC) - $t0;
36 diag "thread_results $elapsed";