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"; }
public function test_addBulk() { $bannedUserIds = array(1, 2, 3, 4, 5, 6); Hashee::addBulk($bannedUserIds); $expected = array(1 => true, 2 => true, 3 => true, 4 => true, 5 => true, 6 => true); $this->assertEquals($expected, $bannedUserIds); $this->assertTrue(Hashee::in(6, $bannedUserIds)); $this->assertFalse(Hashee::in(7, $bannedUserIds)); }