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

Problems in recursive functions #41

Open
larsiusprime opened this issue Aug 15, 2014 · 1 comment
Open

Problems in recursive functions #41

larsiusprime opened this issue Aug 15, 2014 · 1 comment

Comments

@larsiusprime
Copy link

I really like the profiler, but it seems to have trouble with codebases that have a lot of recursion (like Flixel-UI's _loadThing() function).

For instance:

function foo(iteration:Int = 0):Void
{
    DC.beginProfile("foo");
    if (iteration < 10)
    {
        foo(iteration++);
    }
    DC.endProfile("foo");
}

Call foo() from your code, and you will receive the error "foo already started." The problem is sometimes I want to be able to profile a recursive function but there's no easy way to do that if the profiler will throw an error if I begin another foo profile before I finish the last one.

If I do something like this:

private function foo(iteration:Int = 0):Void
{
    DC.beginProfile("foo:"+iteration);
    if (iteration < 10)
    {
        foo(iteration+1);
    }
    DC.endProfile("foo:"+iteration);
}

I can get around it, but it would be handy if the profiler would handle this case internally; it's a pretty common use-case.

@tiagolr
Copy link
Owner

tiagolr commented Aug 17, 2014

I ran into the same problem very quickly using the profiler, I'll have a look soon.

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

No branches or pull requests

2 participants