public function testUnique() { $array = array(10, 100, 1231, 10, 600, 20, 40, 1231, 20, 6, 1); isSame(array(10, 100, 1231, 600, 20, 40, 6, 1), Arr::unique($array)); $array = array('hello', 'world', 'this', 'is', 'a', 'test', 'hello', 'is', 'a', 'word'); isSame(array('hello', 'world', 'this', 'is', 'a', 'test', 'word'), Arr::unique($array, false)); $array = array('asd_1' => 'asd', 'asd_2' => 'asd'); isSame(array('asd_1' => 'asd'), Arr::unique($array, true)); }
public function testFunctionOverhead() { runBench(array('Clean' => function () { return pathinfo(__FILE__, PATHINFO_BASENAME); }, 'Wrapper' => function () { return FS::base(__FILE__); }), array('name' => 'Pathinfo overhead', 'count' => 10000)); runBench(array('Vars::get' => function () { return Vars::get($GLOBALS['somevar']); }, 'isset' => function () { return isset($GLOBALS['somevar']); }), array('name' => 'Isset overhead', 'count' => 10000)); $randArr = array_fill(0, 100, null); for ($i = 0; $i < 100; $i += 1) { $randArr[$i] = mt_rand(0, 9); } runBench(array('array_keys(+flip)' => function () use($randArr) { return Arr::unique($randArr, false); }, 'array_unique' => function () use($randArr) { return Arr::unique($randArr, true); }), array('name' => 'Isset overhead', 'count' => 1000)); }