Created
July 4, 2010 20:04
-
-
Save webmozart/463712 to your computer and use it in GitHub Desktop.
This file contains 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 | |
use Symfony\Foundation\UniversalClassLoader; | |
require_once __DIR__.'/src/Symfony/Foundation/UniversalClassLoader.php'; | |
$loader = new UniversalClassLoader(); | |
$loader->registerNamespace('Symfony', __DIR__.'/src'); | |
$loader->register(); | |
class Test | |
{ | |
protected $a; | |
protected $b; | |
protected $c; | |
protected $d; | |
protected $e; | |
protected $f; | |
protected $g; | |
protected $h; | |
protected $i; | |
protected $j; | |
protected $k; | |
protected $l; | |
} | |
$start = microtime(true); | |
for ($i = 0; $i < 1000; ++$i) { | |
$metadata = include 'metadata.php'; | |
} | |
echo "APC: ".(microtime(true)-$start)."\n"; | |
$start = microtime(true); | |
for ($i = 0; $i < 1000; ++$i) { | |
$metadata = unserialize(file_get_contents('serialized')); | |
} | |
echo "Serialized: ".(microtime(true)-$start)."\n"; | |
$start = microtime(true); | |
apc_store('metadata', file_get_contents('serialized'), 0); | |
for ($i = 0; $i < 1000; ++$i) { | |
$metadata = unserialize(apc_fetch('metadata', $found)); | |
} | |
echo "Serialized + APC: ".(microtime(true)-$start)."\n"; | |
$metadata = unserialize(file_get_contents('serialized')); | |
$start = microtime(true); | |
apc_store('metadata', $metadata, 0); | |
for ($i = 0; $i < 1000; ++$i) { | |
$metadata = apc_fetch('metadata', $found); | |
} | |
echo "Object + APC: ".(microtime(true)-$start)."\n"; |
This file contains 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 | |
use Symfony\Components\Validator\Mapping\ClassMetadata; | |
use Symfony\Components\Validator\Constraints\NotNull; | |
use Symfony\Components\Validator\Constraints\Choice; | |
use Symfony\Components\Validator\Constraints\Min; | |
use Symfony\Components\Validator\Constraints\Max; | |
use Symfony\Components\Validator\Constraints\MinLength; | |
$metadata = new ClassMetadata('Test'); | |
$metadata->addPropertyConstraint('a', new Choice(array("a", "b", "c"))); | |
$metadata->addPropertyConstraint('b', new NotNull()); | |
$metadata->addPropertyConstraint('c', new NotNull()); | |
$metadata->addPropertyConstraint('c', new Min(5)); | |
$metadata->addPropertyConstraint('d', new Choice(array("a", "b", "c"))); | |
$metadata->addPropertyConstraint('e', new NotNull()); | |
$metadata->addPropertyConstraint('e', new Max(10)); | |
$metadata->addPropertyConstraint('f', new NotNull()); | |
$metadata->addPropertyConstraint('g', new NotNull()); | |
$metadata->addPropertyConstraint('h', new Choice(array("a", "b", "c"))); | |
$metadata->addPropertyConstraint('i', new NotNull()); | |
$metadata->addPropertyConstraint('i', new MinLength(2)); | |
$metadata->addPropertyConstraint('j', new NotNull()); | |
$metadata->addPropertyConstraint('k', new Choice(array("a", "b", "c"))); | |
$metadata->addPropertyConstraint('l', new NotNull()); | |
return $metadata; |
This file contains 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
O:50:"Symfony\Components\Validator\Mapping\ClassMetadata":8:{s:11:"constraints";a:0:{}s:18:"constraintsByGroup";a:0:{}s:7:"getters";a:0:{}s:13:"groupSequence";a:0:{}s:7:"members";a:12:{s:1:"a";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:47:"Symfony\Components\Validator\Constraints\Choice":9:{s:7:"choices";a:3:{i:0;s:1:"a";i:1;s:1:"b";i:2;s:1:"c";}s:8:"callback";N;s:8:"multiple";b:0;s:3:"min";N;s:3:"max";N;s:7:"message";s:32:"Symfony.Validator.Choice.message";s:10:"minMessage";s:35:"Symfony.Validator.Choice.minMessage";s:10:"maxMessage";s:35:"Symfony.Validator.Choice.maxMessage";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:10;}s:3:"est";a:1:{i:0;r:10;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"a";s:8:"property";s:1:"a";}}s:1:"b";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:36;}s:3:"est";a:1:{i:0;r:36;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"b";s:8:"property";s:1:"b";}}s:1:"c";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:2:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}i:1;O:44:"Symfony\Components\Validator\Constraints\Min":3:{s:7:"message";s:29:"Symfony.Validator.Min.message";s:5:"limit";i:5;s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:2:{i:0;r:52;i:1;r:57;}s:3:"est";a:2:{i:0;r:52;i:1;r:57;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"c";s:8:"property";s:1:"c";}}s:1:"d";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:47:"Symfony\Components\Validator\Constraints\Choice":9:{s:7:"choices";a:3:{i:0;s:1:"a";i:1;s:1:"b";i:2;s:1:"c";}s:8:"callback";N;s:8:"multiple";b:0;s:3:"min";N;s:3:"max";N;s:7:"message";s:32:"Symfony.Validator.Choice.message";s:10:"minMessage";s:35:"Symfony.Validator.Choice.minMessage";s:10:"maxMessage";s:35:"Symfony.Validator.Choice.maxMessage";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:76;}s:3:"est";a:1:{i:0;r:76;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"d";s:8:"property";s:1:"d";}}s:1:"e";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:2:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}i:1;O:44:"Symfony\Components\Validator\Constraints\Max":3:{s:7:"message";s:29:"Symfony.Validator.Max.message";s:5:"limit";i:10;s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:2:{i:0;r:102;i:1;r:107;}s:3:"est";a:2:{i:0;r:102;i:1;r:107;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"e";s:8:"property";s:1:"e";}}s:1:"f";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:126;}s:3:"est";a:1:{i:0;r:126;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"f";s:8:"property";s:1:"f";}}s:1:"g";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:142;}s:3:"est";a:1:{i:0;r:142;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"g";s:8:"property";s:1:"g";}}s:1:"h";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:47:"Symfony\Components\Validator\Constraints\Choice":9:{s:7:"choices";a:3:{i:0;s:1:"a";i:1;s:1:"b";i:2;s:1:"c";}s:8:"callback";N;s:8:"multiple";b:0;s:3:"min";N;s:3:"max";N;s:7:"message";s:32:"Symfony.Validator.Choice.message";s:10:"minMessage";s:35:"Symfony.Validator.Choice.minMessage";s:10:"maxMessage";s:35:"Symfony.Validator.Choice.maxMessage";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:158;}s:3:"est";a:1:{i:0;r:158;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"h";s:8:"property";s:1:"h";}}s:1:"i";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:2:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}i:1;O:50:"Symfony\Components\Validator\Constraints\MinLength":4:{s:7:"message";s:35:"Symfony.Validator.MinLength.message";s:5:"limit";i:2;s:7:"charset";s:5:"UTF-8";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:2:{i:0;r:184;i:1;r:189;}s:3:"est";a:2:{i:0;r:184;i:1;r:189;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"i";s:8:"property";s:1:"i";}}s:1:"j";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:209;}s:3:"est";a:1:{i:0;r:209;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"j";s:8:"property";s:1:"j";}}s:1:"k";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:47:"Symfony\Components\Validator\Constraints\Choice":9:{s:7:"choices";a:3:{i:0;s:1:"a";i:1;s:1:"b";i:2;s:1:"c";}s:8:"callback";N;s:8:"multiple";b:0;s:3:"min";N;s:3:"max";N;s:7:"message";s:32:"Symfony.Validator.Choice.message";s:10:"minMessage";s:35:"Symfony.Validator.Choice.minMessage";s:10:"maxMessage";s:35:"Symfony.Validator.Choice.maxMessage";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:225;}s:3:"est";a:1:{i:0;r:225;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"k";s:8:"property";s:1:"k";}}s:1:"l";a:1:{i:0;O:53:"Symfony\Components\Validator\Mapping\PropertyMetadata":5:{s:11:"constraints";a:1:{i:0;O:48:"Symfony\Components\Validator\Constraints\NotNull":2:{s:7:"message";s:33:"Symfony.Validator.NotNull.message";s:6:"groups";a:2:{i:0;s:7:"Default";i:1;s:3:"est";}}}s:18:"constraintsByGroup";a:2:{s:7:"Default";a:1:{i:0;r:251;}s:3:"est";a:1:{i:0;r:251;}}s:5:"class";s:4:"Test";s:4:"name";s:1:"l";s:8:"property";s:1:"l";}}}s:4:"name";s:4:"Test";s:10:"properties";a:12:{s:1:"a";r:8;s:1:"b";r:34;s:1:"c";r:50;s:1:"d";r:74;s:1:"e";r:100;s:1:"f";r:124;s:1:"g";r:140;s:1:"h";r:156;s:1:"i";r:182;s:1:"j";r:207;s:1:"k";r:223;s:1:"l";r:249;}s:9:"shortName";s:3:"est";} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment