This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$intervalsCount = 100; | |
$days = range(0, 100); | |
//shuffle($days); | |
$iteratedDays = array_slice($days, 0, $intervalsCount); | |
$intervals = []; | |
foreach ($iteratedDays as $days) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$iterations = 10**6; | |
class SomeVeryLongNameForCompareWithSomeVeryPerfectMethodOrStrategyAndSomeOtherWordsInThisName {} | |
class Short{} | |
function checkInstanceOfLongClassName($val): bool { | |
return $val instanceof SomeVeryLongNameForCompareWithSomeVeryPerfectMethodOrStrategyAndSomeOtherWordsInThisName; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$iterations = 10**7; | |
$part1 = 'some_part1_string'; | |
$part2 = 'some_part2_string'; | |
$part3 = 'some_part3_string'; | |
$part4 = 'some_part4_string'; | |
function singleQuotesConcat(string $p1, string $p2, string $p3, string $p4): string { | |
return $p1 . '-' . $p2 . '-' . $p3 . '-' . $p4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$iterations = 10; | |
$originValuesTo = 10000; | |
$duplicateValuesTo = 10000; | |
$duplicatesCount = 2; | |
$a = range(0, $originValuesTo); | |
$b = range(0, $duplicateValuesTo); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
function getLastIdx(string $strInt): int { | |
return '' === $strInt ? -1 : strlen($strInt) - 1; | |
} | |
function getDigitByIdx(string $strInt, int $idx): int { | |
return $idx >= 0 ? (int) $strInt[$idx] : 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
$arraysCount = 100; | |
$itemsInArray = 100; | |
$dataToMerge = []; | |
for ($i = 0; $i < $arraysCount; ++$i) { | |
for ($j = 0; $j < $itemsInArray; ++$j) { | |
$dataToMerge[$i][] = uniqid('', true); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$iterations = 10000000; | |
$defaultString = 'Test string m8'; | |
$replaceTpl = 'm8'; | |
$placeholder = 'is more effective'; | |
$start = microtime(true); | |
for ($i = 0; $i < $iterations; ++$i) { | |
$out = str_replace($replaceTpl, $placeholder, $defaultString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = null; | |
$key = null; | |
$startIdx = 0; | |
$func = function() use (&$a, &$key, &$startIdx) { | |
$a = array_fill_keys(range($startIdx, $startIdx+=1000), null); | |
$key = $startIdx + 1; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestResult | |
{ | |
/** | |
* @var int | |
*/ | |
private $count; | |
/** | |
* @var float |