Skip to content

Instantly share code, notes, and snippets.

postpersonality

Block or report user

Report or block postpersonality

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View php: double quotes vs single quotes
// Benchmark params
$runs = 100000000;
// Gen test array
$strMatch = 'test string';
echo 'Benchmark runs: ' . $runs . PHP_EOL;
// Benchmark isset
$timeStart = microtime(true);
View php: interpolation vs concatenation
// Benchmark params
$runs = 10000000;
// Gen test array
$testStr = 'string';
$testInt = -100;
$testFloat = .1;
$testArr = [$testStr, 'key' => $testInt];
$testObj = new \StdClass();
$testObj->{0} = $testStr;
View php: isset vs array_key_exists
// 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;
}
You can’t perform that action at this time.