diff options
author | Eric Wong <e@80x24.org> | 2023-01-29 10:30:41 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-01-30 06:42:31 +0000 |
commit | e6aa13bccb7ea5d5b3246b3a944621515905e360 (patch) | |
tree | 822309b8cc2ac85ba50acd33deebb03891b0844b /lib/PublicInbox/LeiSucks.pm | |
parent | 9eb8baf199cd148b7ebf8e6e130fb832f4e1ef00 (diff) | |
download | public-inbox-e6aa13bccb7ea5d5b3246b3a944621515905e360.tar.gz |
On my x86-64 machine, OpenSSL SHA-256 is nearly twice as fast as the Digest::SHA implementation from Perl, most likely due to an optimized assembly implementation. SHA-1 is a few percent faster, too.
Diffstat (limited to 'lib/PublicInbox/LeiSucks.pm')
-rw-r--r-- | lib/PublicInbox/LeiSucks.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/LeiSucks.pm b/lib/PublicInbox/LeiSucks.pm index 8e866fc9..35d0a8de 100644 --- a/lib/PublicInbox/LeiSucks.pm +++ b/lib/PublicInbox/LeiSucks.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2021 all contributors <meta@public-inbox.org> +# Copyright (C) all contributors <meta@public-inbox.org> # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> # Undocumented hidden command somebody might discover if they're @@ -7,7 +7,7 @@ package PublicInbox::LeiSucks; use strict; use v5.10.1; -use Digest::SHA (); +use PublicInbox::SHA qw(sha1_hex); use Config; use POSIX (); use PublicInbox::Config; @@ -54,13 +54,13 @@ sub lei_sucks { } else { push @out, "Xapian not available: $@\n"; } - my $dig = Digest::SHA->new(1); push @out, "public-inbox blob OIDs of loaded features:\n"; for my $m (grep(m{^PublicInbox/}, sort keys %INC)) { my $f = $INC{$m} // next; # lazy require failed (missing dep) - $dig->add('blob '.(-s $f)."\0"); - $dig->addfile($f); - push @out, ' '.$dig->hexdigest.' '.$m."\n"; + open my $fh, '<', $f or do { warn "open($f): $!"; next }; + my $hex = sha1_hex('blob '.(-s $fh)."\0". + (do { local $/; <$fh> } // die("read: $!"))); + push @out, ' '.$hex.' '.$m."\n"; } push @out, <<'EOM'; Let us know how it sucks! Please include the above and any other |