about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-07 03:41:54 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-04-07 03:42:30 +0000
commit74b92712fa7a21fe504b9908edebcf11bb9dc170 (patch)
treecf4abdc1b8d8a64151fdcbacd095942fa227ff8e /t
parent3348ad4b3b1a0865ee58a902953165ea0f4aa4bd (diff)
downloadpublic-inbox-74b92712fa7a21fe504b9908edebcf11bb9dc170.tar.gz
This significantly improves the performance of the NNTP GROUP
command with 2.7 million messages from over 250ms to 700us.
SQLite is weird about this, but at least there's a way to
optimize it.
Diffstat (limited to 't')
-rw-r--r--t/perf-nntpd.t13
1 files changed, 9 insertions, 4 deletions
diff --git a/t/perf-nntpd.t b/t/perf-nntpd.t
index 4987f981..e5021532 100644
--- a/t/perf-nntpd.t
+++ b/t/perf-nntpd.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use Test::More;
-use Benchmark qw(:all);
+use Benchmark qw(:all :hireswallclock);
 use PublicInbox::Inbox;
 use File::Temp qw/tempdir/;
 use POSIX qw(dup2);
@@ -79,8 +79,13 @@ $s = IO::Socket::INET->new(%opts);
 $s->autoflush(1);
 my $buf = $s->getline;
 is($buf, "201 server ready - post via email\r\n", 'got greeting');
-ok($s->print("GROUP $group\r\n"), 'changed group');
-$buf = $s->getline;
+
+my $t = timeit(10, sub {
+        ok($s->print("GROUP $group\r\n"), 'changed group');
+        $buf = $s->getline;
+});
+diag 'GROUP took: ' . timestr($t);
+
 my ($tot, $min, $max) = ($buf =~ /\A211 (\d+) (\d+) (\d+) /);
 ok($tot && $min && $max, 'got GROUP response');
 my $nr = $max - $min;
@@ -100,7 +105,7 @@ sub read_until_dot ($) {
         $n;
 }
 
-my $t = timeit(1, sub {
+$t = timeit(1, sub {
         $s->print("XOVER $spec\r\n");
         $n = read_until_dot($s);
 });