示例#1
0
 public function test_release()
 {
     $bannedUserIds = array(1, 2, 3, 4, 5);
     Hashee::addBulk($bannedUserIds);
     Hashee::release($bannedUserIds);
     $this->assertEmpty($bannedUserIds);
 }
示例#2
0
 public function bench($elementNumber)
 {
     echo "========================================\n";
     echo "elementNumber : " . $elementNumber . "\n";
     $total = 10000;
     $paragraph = 'how are you today?';
     $words = explode(' ', $paragraph);
     // Create a bunch of letter entries
     $sequence = array();
     for ($j = 0; $j < $elementNumber; $j++) {
         $sequence[] = 'a' . $j;
     }
     $s = microtime(true);
     for ($j = 0; $j < $total; $j++) {
         foreach ($words as $word) {
             in_array(strtolower($word), $sequence);
         }
     }
     echo "in_array: " . (microtime(true) - $s) . "\n";
     // Convert the array to a hash
     Hashee::addBulk($sequence);
     $s = microtime(true);
     for ($j = 0; $j < $total; $j++) {
         foreach ($words as $word) {
             Hashee::in($word, $sequence);
         }
     }
     echo "hashee:   " . (microtime(true) - $s) . "\n";
     echo "========================================\n";
 }