Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98727 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79393 invoked from network); 3 Apr 2017 21:12:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2017 21:12:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=lauri.kentta@gmail.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=lauri.kentta@gmail.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain gmail.com does not designate 178.62.210.197 as permitted sender) X-PHP-List-Original-Sender: lauri.kentta@gmail.com X-Host-Fingerprint: 178.62.210.197 k-piste.dy.fi Received: from [178.62.210.197] ([178.62.210.197:52350] helo=k-piste.dy.fi) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/16-28750-ECAB2E85 for ; Mon, 03 Apr 2017 17:12:46 -0400 Received: from localhost.localdomain ([::1] helo=k-piste.dy.fi) by k-piste.dy.fi with esmtp (Exim 4.88) (envelope-from ) id 1cv9H2-0002wU-BP; Tue, 04 Apr 2017 00:12:28 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 04 Apr 2017 00:12:27 +0300 To: Christian Schneider Cc: Yasuo Ohgaki , internals@lists.php.net In-Reply-To: <45858E8B-05A8-4EAB-97B0-A17C3D8BDD96@cschneid.com> References: <45858E8B-05A8-4EAB-97B0-A17C3D8BDD96@cschneid.com> Message-ID: <9fac5096291d983e5ca2f09af60b4b2f@koti.fimnet.fi> X-Sender: lauri.kentta@gmail.com User-Agent: Roundcube Webmail/1.2.4 Subject: Re: [PHP-DEV] SHA3 is very slow From: lauri.kentta@gmail.com (=?UTF-8?Q?Lauri_Kentt=C3=A4?=) On 2017-04-03 14:44, Christian Schneider wrote: > Am 01.04.2017 um 05:12 schrieb Yasuo Ohgaki : >> I noticed that our SHA-3 is inefficient. >> >> === Ruby SHA3-256 === >> [yohgaki@dev ~]$ cat t2.rb >> #!/usr/bin/env ruby >> >> require 'digest/sha2' >> >> $i = 1000000 >> until $i do >> Digest::SHA3.hexdigest("abcdedf", 256) >> $i -= 1 >> end > > Two things I noticed: > 1) As far as I understand Ruby (and as far as I tested it) this does > not execute the function at all. Why am I not surprised... > 2) For some reason the Ruby implementation yields different results, I > didn't track down why. Here's another library, which actually works. https://rubygems.org/gems/sha3 Tests with that one: time ruby -e 'require "sha3"; 123456.times { SHA3::Digest::SHA256.hexdigest("abc") }' user 0m1.597s sys 0m0.023s time php -r 'for ($i = 0; $i < 123456; ++$i) hash("sha3-256", "abc");' user 0m2.497s sys 0m0.020s There's a small difference, but I wonder if anybody (except Yasuo) actually cares? -- Lauri Kenttä