Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何控制for循环下的重复抓取 #47

Open
oikomi opened this issue Dec 21, 2015 · 1 comment
Open

如何控制for循环下的重复抓取 #47

oikomi opened this issue Dec 21, 2015 · 1 comment
Assignees
Labels

Comments

@oikomi
Copy link

oikomi commented Dec 21, 2015

对于下面的代码, 它会打印 strpos栈 200次,显然对性能影响极大,有没有办法控制打印的次数呢

function test() {
        for ($idx = 0; $idx < 200; $idx++) {
                strpos("You love php, I love php too!","php");
        }
}
@monque monque added the feature label Mar 14, 2016
@monque monque self-assigned this Mar 14, 2016
@monque monque added question and removed feature labels Mar 14, 2016
@monque
Copy link
Collaborator

monque commented Mar 14, 2016

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants