tmaiaroto/li3_perf — Issue #9: Optimize variable size calculation in Li3perf.php
Author: mariano
Created: 2012-01-12 03:48:35+00:00
State: open

So I was looking at the `Li3perf::varsize()` method. I totally get how doing the actual memory calculation of a copied variable seems to be the only real, practical way of getting the variable size.

However, wouldn't it be much simpler if instead of manually copying the variable, do an unserialize & serialize? Like so:

```php
$current_mem = memory_get_usage();
$tmp_var = unserialize(serialize($var));
$variable_size = memory_get_usage() - $current_mem;
unset($tmp_var);
```

I'm asking because you may have already looked into this approach. I've quickly tested this and it produces the same output as the `_varCopy()` approach.

If you are comfortable with this change, I can go ahead and make a pull request.