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

MethodScanner performance issue #939

Closed
lsuski opened this issue Dec 7, 2015 · 6 comments
Closed

MethodScanner performance issue #939

lsuski opened this issue Dec 7, 2015 · 6 comments

Comments

@lsuski
Copy link
Contributor

lsuski commented Dec 7, 2015

Hi,
I found that MethodScanner scan() method

 public void scan(JavaBackend javaBackend, List<String> gluePaths) {
        for (String gluePath : gluePaths) {
            for (Class<?> glueCodeClass : classFinder.getDescendants(Object.class, packageName(gluePath))) {
                while (glueCodeClass != null && glueCodeClass != Object.class && !Utils.isInstantiable(glueCodeClass)) {
                    // those can't be instantiated without container class present.
                    glueCodeClass = glueCodeClass.getSuperclass();
                }
                if (glueCodeClass != null) {
                    for (Method method : glueCodeClass.getMethods()) {
                        scan(javaBackend, method, glueCodeClass);
                    }
                }
            }
        }
    }

is very unoptimal for annonymous classes and generally not instantiable classes. For those classes glueCodeClass variable becomes Object.class which is useless. Then method scan() checks Object public methods against appearance of about 400 possible cucumber.api annotations

@aslakhellesoy
Copy link
Contributor

Do you have any benchmark numbers? Any suggestions?

@lsuski
Copy link
Contributor Author

lsuski commented Dec 7, 2015

I found this while resolving issue with Android Studio 1.5.0 debugger, starting tests with debug takes very long, about 10-15 minutes, and I found that execution hangs on scan method. Without debug it executes normally so it's not really cucumber issue. I think that adding this would be sufficient

if (glueCodeClass != null && glueCodeClass != Object.class) {
                    for (Method method : glueCodeClass.getMethods()) {
                        scan(javaBackend, method, glueCodeClass);
                    }
                }

@aslakhellesoy
Copy link
Contributor

Feel free to send a pull request. You're in the best position to judge how well it works for you.

@dherges
Copy link

dherges commented Aug 2, 2016

reference from 1034 was typo. please ignore. no relation between the two.

@mpkorstanje
Copy link
Contributor

Closing. It appears this issue has been resolved a while ago.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants