Skip to content

Instantly share code, notes, and snippets.

@sreichel
Created April 20, 2023 23:17
Show Gist options
  • Save sreichel/067428567d49c9ceab907fd10a36e2dc to your computer and use it in GitHub Desktop.
Save sreichel/067428567d49c9ceab907fd10a36e2dc to your computer and use it in GitHub Desktop.
Compare Zend_Validate to laminas-validate
$string = '';

if (!Zend_Validate::is($string, 'NotEmpty')) {
    echo 'error';
}

$validator = new \Laminas\Validator\NotEmpty();
if (!$validator->isValid($string)) {
    echo 'error';
}

$validator = new \Zend_Validate_NotEmpty();
if (!$validator->isValid($string)) {
    echo 'error';
}

PHP 7.4 - Zend_Validate::is()

Function NameCallsCalls%Incl. Wall Time
(microsec)
IWall%Incl. CPU
(microsecs)
ICpu%Incl.
MemUse
(bytes)
IMemUse%Incl.
PeakMemUse
(bytes)
IPeakMemUse%
Current Function
Zend_Validate::is1 2.8% 155 0.0% 0 0.0% 141,176 9.5% 0 0.0%
Exclusive Metrics for Current Function25 16.1% 0 N/A% -136 -0.1% 0 N/A%
Parent function
main()1 100.0% 155 100.0% 0 N/A% 141,176 100.0% 0 N/A%
Child functions
Zend_Loader::loadClass1 8.3% 58 37.4% 0 N/A% 118,072 83.6% 0 N/A%
Zend_Validate_NotEmpty::isValid1 8.3% 41 26.5% 0 N/A% 12,840 9.1% 0 N/A%
Zend_Loader::isReadable1 8.3% 21 13.5% 0 N/A% 4,216 3.0% 0 N/A%
ReflectionClass::newInstance1 8.3% 4 2.6% 0 N/A% 1,440 1.0% 0 N/A%
array_merge1 8.3% 1 0.6% 0 N/A% 904 0.6% 0 N/A%
ucfirst1 8.3% 1 0.6% 0 N/A% 528 0.4% 0 N/A%
class_exists1 8.3% 1 0.6% 0 N/A% 536 0.4% 0 N/A%
ReflectionClass::__construct1 8.3% 1 0.6% 0 N/A% 552 0.4% 0 N/A%
ReflectionClass::hasMethod1 8.3% 1 0.6% 0 N/A% 552 0.4% 0 N/A%
array_keys1 8.3% 1 0.6% 0 N/A% 528 0.4% 0 N/A%
str_replace1 8.3% 0 0.0% 0 N/A% 576 0.4% 0 N/A%
ReflectionClass::implementsInterface1 8.3% 0 0.0% 0 N/A% 568 0.4% 0 N/A%

PHP 7.4 - Zend_Validate_NotEmpty->isValid()

Function NameCallsCalls%Incl. Wall Time
(microsec)
IWall%Incl. CPU
(microsecs)
ICpu%Incl.
MemUse
(bytes)
IMemUse%Incl.
PeakMemUse
(bytes)
IPeakMemUse%
Current Function
Zend_Validate_NotEmpty::isValid1 3.3% 72 0.0% 0 0.0% 78,376 5.5% 0 0.0%
Exclusive Metrics for Current Function10 13.9% 0 N/A% 808 1.0% 0 N/A%
Parent function
main()1 100.0% 72 100.0% 0 N/A% 78,376 100.0% 0 N/A%
Child functions
Zend_Validate_Abstract::_error1 25.0% 58 80.6% 0 N/A% 75,880 96.8% 0 N/A%
preg_match1 25.0% 3 4.2% 0 N/A% 552 0.7% 0 N/A%
Zend_Validate_Abstract::_setValue1 25.0% 1 1.4% 0 N/A% 568 0.7% 0 N/A%
Zend_Validate_NotEmpty::getType1 25.0% 0 0.0% 0 N/A% 568 0.7% 0 N/A%

PHP 7.4 - Laminas\Validate\NotEmpty->isValid()

Function NameCallsCalls%Incl. Wall Time
(microsec)
IWall%Incl. CPU
(microsecs)
ICpu%Incl.
MemUse
(bytes)
IMemUse%Incl.
PeakMemUse
(bytes)
IPeakMemUse%
Current Function
Laminas\Validator\NotEmpty::isValid1 3.4% 48 0.0% 0 0.0% 49,920 3.4% 0 0.0%
Exclusive Metrics for Current Function8 16.7% 0 N/A% 808 1.6% 0 N/A%
Parent function
main()1 100.0% 48 100.0% 0 N/A% 49,920 100.0% 0 N/A%
Child functions
Laminas\Validator\AbstractValidator::error1 25.0% 37 77.1% 0 N/A% 47,392 94.9% 0 N/A%
Laminas\Validator\NotEmpty::getType1 25.0% 1 2.1% 0 N/A% 584 1.2% 0 N/A%
Laminas\Validator\AbstractValidator::setValue1 25.0% 1 2.1% 0 N/A% 584 1.2% 0 N/A%
preg_match1 25.0% 1 2.1% 0 N/A% 552 1.1% 0 N/A%

PHP 8.1 - Zend_Validate::is()

Function NameCallsCalls%Incl. Wall Time
(microsec)
IWall%Incl. CPU
(microsecs)
ICpu%Incl.
MemUse
(bytes)
IMemUse%Incl.
PeakMemUse
(bytes)
IPeakMemUse%
Current Function
Zend_Validate::is1 2.8% 127 0.0% 0 0.0% 28,160 3.0% 0 0.0%
Exclusive Metrics for Current Function25 19.7% 0 N/A% 1,216 4.3% 0 N/A%
Parent function
main()1 100.0% 127 100.0% 0 N/A% 28,160 100.0% 0 N/A%
Child functions
Zend_Validate_NotEmpty::isValid1 8.3% 38 29.9% 0 N/A% 9,632 34.2% 0 N/A%
Zend_Loader::loadClass1 8.3% 32 25.2% 0 N/A% 6,720 23.9% 0 N/A%
Zend_Loader::isReadable1 8.3% 22 17.3% 0 N/A% 4,408 15.7% 0 N/A%
ReflectionClass::newInstance1 8.3% 3 2.4% 0 N/A% 1,440 5.1% 0 N/A%
ReflectionClass::hasMethod1 8.3% 2 1.6% 0 N/A% 552 2.0% 0 N/A%
array_merge1 8.3% 1 0.8% 0 N/A% 904 3.2% 0 N/A%
ucfirst1 8.3% 1 0.8% 0 N/A% 528 1.9% 0 N/A%
ReflectionClass::__construct1 8.3% 1 0.8% 0 N/A% 552 2.0% 0 N/A%
ReflectionClass::implementsInterface1 8.3% 1 0.8% 0 N/A% 568 2.0% 0 N/A%
array_keys1 8.3% 1 0.8% 0 N/A% 528 1.9% 0 N/A%
class_exists1 8.3% 0 0.0% 0 N/A% 536 1.9% 0 N/A%
str_replace1 8.3% 0 0.0% 0 N/A% 576 2.0% 0 N/A%

PHP 8.1 - Zend_Validate_NotEmpty->isValid()

Function NameCallsCalls%Incl. Wall Time
(microsec)
IWall%Incl. CPU
(microsecs)
ICpu%Incl.
MemUse
(bytes)
IMemUse%Incl.
PeakMemUse
(bytes)
IPeakMemUse%
Current Function
Zend_Validate_NotEmpty::isValid1 3.4% 67 0.0% 0 0.0% 9,632 1.1% 0 0.0%
Exclusive Metrics for Current Function12 17.9% 0 N/A% 808 8.4% 0 N/A%
Parent function
main()1 100.0% 67 100.0% 0 N/A% 9,632 100.0% 0 N/A%
Child functions
Zend_Validate_Abstract::_error1 25.0% 39 58.2% 0 N/A% 7,136 74.1% 0 N/A%
preg_match1 25.0% 14 20.9% 0 N/A% 552 5.7% 0 N/A%
Zend_Validate_NotEmpty::getType1 25.0% 1 1.5% 0 N/A% 568 5.9% 0 N/A%
Zend_Validate_Abstract::_setValue1 25.0% 1 1.5% 0 N/A% 568 5.9% 0 N/A%

PHP 8.1 - Laminas\Validate\NotEmpty->isValid()

Function NameCallsCalls%Incl. Wall Time
(microsec)
IWall%Incl. CPU
(microsecs)
ICpu%Incl.
MemUse
(bytes)
IMemUse%Incl.
PeakMemUse
(bytes)
IPeakMemUse%
Current Function
Laminas\Validator\NotEmpty::isValid1 3.4% 74 0.0% 0 0.0% 9,056 1.0% 0 0.0%
Exclusive Metrics for Current Function13 17.6% 0 N/A% 808 8.9% 0 N/A%
Parent function
main()1 100.0% 74 100.0% 0 N/A% 9,056 100.0% 0 N/A%
Child functions
preg_match1 25.0% 39 52.7% 0 N/A% 552 6.1% 0 N/A%
Laminas\Validator\AbstractValidator::error1 25.0% 20 27.0% 0 N/A% 6,528 72.1% 0 N/A%
Laminas\Validator\NotEmpty::getType1 25.0% 1 1.4% 0 N/A% 584 6.4% 0 N/A%
Laminas\Validator\AbstractValidator::setValue1 25.0% 1 1.4% 0 N/A% 584 6.4% 0 N/A%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment