bench-shake256-squeeze.php 604 B

1234567891011121314151617181920212223242526
  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::SHAKE256);
  10. $sponge->absorb ('');
  11. for ($i = 0; $i < 1024; ++$i) {
  12. $sponge->squeeze (1024);
  13. }
  14. $end = microtime ();
  15. $start = explode (' ', $start);
  16. $end = explode (' ', $end);
  17. printf ("Squeezed %d Bytes in %.6f seconds\n"
  18. , $length
  19. , ($end[1] - $start[1]) + ($end[0] - $start[0]));