bench-224.php 590 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env php
  2. <?php /* -*- coding: utf-8; indent-tabs-mode: t; tab-width: 4 -*-
  3. vim: ts=4 noet ai */
  4. use desktopd\SHA3\Sponge as SHA3;
  5. require __DIR__ . '/namespaced/desktopd/SHA3/Sponge.php';
  6. $length = 1024 * 1024; // 1MiB
  7. $data = str_repeat ("\0", $length);
  8. $start = microtime ();
  9. $sponge = SHA3::init (SHA3::SHA3_224);
  10. $sponge->absorb ($data);
  11. $hash = $sponge->squeeze ();
  12. $end = microtime ();
  13. $start = explode (' ', $start);
  14. $end = explode (' ', $end);
  15. printf ("%d Bytes in %.6f seconds\n%s\n"
  16. , $length
  17. , ($end[1] - $start[1]) + ($end[0] - $start[0])
  18. , bin2hex ($hash));