phptrace
phptrace copied to clipboard
如何控制for循环下的重复抓取
对于下面的代码, 它会打印 strpos栈 200次,显然对性能影响极大,有没有办法控制打印的次数呢
function test() {
for ($idx = 0; $idx < 200; $idx++) {
strpos("You love php, I love php too!","php");
}
}
Strictly speaking, this code snippet do affect performance.
for some simple code, perhaps phptrace can do some merging operation to reduce the output size like this
> strpos("You love php, I love php too!", "php") called at [try.php:5] x 200
< strpos("You love php, I love php too!", "php") = 9 called at [try.php:5] x 200
But, we can not explicitly say what the simple is.
Such this, I just add a variable in string.
function test() {
for ($idx = 0; $idx < 200; $idx++) {
strpos("You love php, I love php too! $idx","php"); // notice this $idx
}
}
It makes the problem more difficult.
Luckily, phptrace still can support for this by doing some runtime-analyzing, and merging similar operations, but it's too complex to implement. (Sounds like JIT)
So I'm curious what you want to trace? could you send a full example?