On 2017-04-03 14:44, Christian Schneider wrote:
Am 01.04.2017 um 05:12 schrieb Yasuo Ohgaki <yohg...@ohgaki.net>:
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ä

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to