user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] xt/perf-msgview: update to use git->cat_async
@ 2020-04-06 23:16 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2020-04-06 23:16 UTC (permalink / raw)
  To: meta

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();

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-06 23:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 23:16 [PATCH] xt/perf-msgview: update to use git->cat_async Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).