Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Create massive variable
- Mem::start();
- $string = str_repeat('a', 5000000);
- Mem::report('Creating $string: %s');
- Mem::start();
- $rawValue = new Phalcon\Db\RawValue($string);
- Mem::report('Creating Phalcon RawValue: %s');
- Mem::start();
- $tmp = $rawValue->getValue();
- Mem::report('Getting Phalcon string back: %s');
- Mem::start();
- $tmp2 = $rawValue->getValue();
- Mem::report('Getting Phalcon string back again: %s');
- echo "\n";
- Mem::start();
- $string2 = str_repeat('a', 5000000);
- Mem::report('Creating $string2: %s');
- Mem::start();
- $phpRawValue = new PhpRawValue($string2);
- Mem::report('Creating PhpRawValue: %s');
- Mem::start();
- $tmpPhp = $phpRawValue->getValue();
- Mem::report('Getting PHP string back: %s');
- Mem::start();
- $tmpPhp2 = $phpRawValue->getValue();
- Mem::report('Getting PHP string back again: %s');
- //---Functions--------------------------------------------
- class Mem
- {
- protected static $_start;
- public static function start()
- {
- self::$_start = memory_get_usage();
- }
- public static function report($message)
- {
- $current = memory_get_usage();
- $difference = ($current - self::$_start) / 1000000;
- echo sprintf($message, sprintf('%.2fM', $difference));
- echo "\n";
- }
- }
- class PhpRawValue
- {
- protected $_value;
- public function __construct($value)
- {
- $this->_value = $value;
- }
- public function getValue()
- {
- return $this->_value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement