Re: SHA3 is very slow
| From: | Lauri Kenttä | Date: | Mon, 03 Apr 2017 21:12:27 +0000 |
| Subject: | Re: SHA3 is very slow | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98727@lists.php.net to get a copy of this message | ||
On 2017-04-03 14:44, Christian Schneider wrote:
Am 01.04.2017 um 05:12 schrieb Yasuo Ohgaki <yohgaki@ohgaki.net>:Why am I not surprised...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 endTwo 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.
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.023stime php -r 'for ($i = 0; $i < 123456; ++$i) hash("sha3-256", "abc");'
user 0m2.497s sys 0m0.020sThere's a small difference, but I wonder if anybody (except Yasuo) actually cares? -- Lauri Kenttä