$stat['bloom']['insert']['e'] = get_stat(); /* * Insert to array **/ $stat['foe']['insert']['s'] = get_stat(); //for( $i = 0; $i < $number; $i++ ) $foe->add($vars); $stat['foe']['insert']['e'] = get_stat(); while (count($check) < $number / 2) { $check[] = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10); } /* * Check existance with bloom **/ $stat['bloom']['has']['s'] = get_stat(); $stat['bloom']['has']['errors'] = $bloom->has($check); $stat['bloom']['has']['e'] = get_stat(); /* * Check existance in array **/ $stat['foe']['has']['s'] = get_stat(); for ($i = 0; $i < $number; $i++) { $stat['foe']['has']['errors'][] = $foe->has($check[$i]); } $stat['foe']['has']['e'] = get_stat(); /* * Results **/ $result['bloom']['insert']['time'] = $stat['bloom']['insert']['e']['timestamp'] - $stat['bloom']['insert']['s']['timestamp']; $result['foe']['insert']['time'] = $stat['foe']['insert']['e']['timestamp'] - $stat['foe']['insert']['s']['timestamp']; $result['bloom']['insert']['mem'] = $stat['bloom']['insert']['e']['memory'] - $stat['bloom']['insert']['s']['memory'];
/* * Init object for 10 entries * counter option is required for delete ability but it much slower **/ $bloom = new Bloom(array('entries_max' => 10, 'counter' => true)); while (count($vars) < 10) { $vars[] = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 5); } /* * Set 10 values to object **/ $bloom->set($vars); /* * Check existance of one object, return boolean **/ echo $bloom->has($vars[rand(0, count($vars) - 1)]), NL; /* * Check existance of one object, return number of Hashes aprovemts **/ echo $bloom->has($vars[rand(0, count($vars) - 1)], false), NL; /* * Check existance of many objects, return boolean **/ echo json_encode($bloom->has(array_slice($vars, 0, 6))), NL; /* * Check existance of many objects, return number of Hashes aprovemts **/ echo json_encode($bloom->has(array_slice($vars, 0, 6), false)), NL; /* * Try to delete one object, returns true **/