unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH] xt/perf-msgview: update to use git->cat_async
Date: Mon,  6 Apr 2020 23:16:27 +0000	[thread overview]
Message-ID: <20200406231627.21428-1-e@yhbt.net> (raw)

It's about 5-10% faster on an SMP machine with an SSD,
even on a hot Linux page cache.
---
 xt/perf-msgview.t | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/xt/perf-msgview.t b/xt/perf-msgview.t
index 3ea92ec6..a4445959 100644
--- a/xt/perf-msgview.t
+++ b/xt/perf-msgview.t
@@ -32,22 +32,30 @@ my $ctx = {
 	-inbox => $ibx,
 	www => Plack::Util::inline_object(style => sub {''}),
 };
-my ($str, $mime, $res, $cmt, $type);
+my ($mime, $res, $oid, $type);
 my $n = 0;
+my $obuf = '';
+my $m = 0;
+
+my $cb = sub {
+	$mime = PublicInbox::MIME->new(shift);
+	PublicInbox::View::multipart_text_as_html($mime, $ctx);
+	++$m;
+	$obuf = '';
+};
+
+$git->cat_async_begin;
 my $t = timeit(1, sub {
-	my $obuf = '';
 	$ctx->{obuf} = \$obuf;
 	$ctx->{mhref} = '../';
 	while (<$fh>) {
-		($cmt, $type) = split / /;
+		($oid, $type) = split / /;
 		next if $type ne 'blob';
 		++$n;
-		$str = $git->cat_file($cmt);
-		$mime = PublicInbox::MIME->new($str);
-		PublicInbox::View::multipart_text_as_html($mime, $ctx);
-		$obuf = '';
+		$git->cat_async($oid, $cb);
 	}
+	$git->cat_async_wait;
 });
-diag 'multipart_text_as_html took '.timestr($t)." for $n messages";
-ok 1;
+diag 'multipart_text_as_html took '.timestr($t)." for $n <=> $m messages";
+is($m, $n, 'rendered all messages');
 done_testing();

                 reply	other threads:[~2020-04-06 23:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200406231627.21428-1-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).