Skip to content

Instantly share code, notes, and snippets.

View postpersonality's full-sized avatar

Nikolay Seliverstov postpersonality

View GitHub Profile
// Benchmark params
$runs = 100000000;
// Gen test array
$strMatch = 'test string';
echo 'Benchmark runs: ' . $runs . PHP_EOL;
// Benchmark isset
$timeStart = microtime(true);
// Benchmark params
$runs = 10000000;
// Gen test array
$testStr = 'string';
$testInt = -100;
$testFloat = .1;
$testArr = [$testStr, 'key' => $testInt];
$testObj = new \StdClass();
$testObj->{0} = $testStr;
// Benchmark params
$arrLen = 100000;
$missRate = 10;
$runs = 10000000;
// Gen test array
$array = [];
for ($i = 0; $i < $arrLen; $i++) {
$array[$arrLen * $missRate + rand(0, $missRate)] = true;
}