Skip to content

Instantly share code, notes, and snippets.

@JudeRosario
Last active May 23, 2017 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JudeRosario/14a6eefedf7e78a6bc176c8ea7d42012 to your computer and use it in GitHub Desktop.
Save JudeRosario/14a6eefedf7e78a6bc176c8ea7d42012 to your computer and use it in GitHub Desktop.
$trie = new Trie();
$start = microtime(true);
for ( $i = 0 ; $i < 20000000 ; $i++ ) {
$sid = bin2hex(openssl_random_pseudo_bytes(8));
$collision = $trie->search($sid) ;
if ( is_null($collision) ) {
$trie->add($sid, 1);
} else {
echo "\n" ."Collision with previous Hash" ."\n" ;
}
}
$time_elapsed_secs = microtime(true) - $start;
echo "\n" . " Time Elapsed :" . $time_elapsed_secs . "\n" ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment