Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function generateRandomString($length = 10) {
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $randomString = '';
- for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, strlen($characters) - 1)]; }
- return $randomString;
- }
- class obj {
- public $items = array();
- public $data;
- }
- function subobj($obj, $depth=5) {
- for($i = 0; $i < 5; $i++) {
- $obj->items[$i] = new obj;
- $obj->items[$i]->data = generateRandomString(64);
- if($depth>1) subobj($obj->items[$i], $depth-1);
- }
- }
- print "Populating object...";
- $obj = new obj;
- for($i = 0; $i < 10; $i++) {
- subobj($obj);
- }
- print "\nSerializing...";
- $data = serialize($obj);
- print "\nLooping...\n";
- $iterations = 20000;
- while($iterations--) {
- $newstr = unserialize($data);
- if($iterations % 1000 == 0)
- print "$iterations: " . sprintf('%0.2f', memory_get_usage()/1024/1024) . "Mb\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement