JasperFx / baseline

Grab bag of generic utilities and extension methods for .Net development
Apache License 2.0
110 stars 21 forks source link

Topological Sort taking too much time #19

Closed cothman closed 4 years ago

cothman commented 4 years ago

Actually We are migrating from StructureMap to Lamar, During the changes we noticed that a new API was introduced BaseLineTypeDiscovery. At first sight the call to AssemblyFinder.FindAssemblies(...) doesn't seem to change, but we also noticed that it take too much time to return the result. bellow the calling code

static string[] namespaces = new[] { "OurProject" };

public static IEnumerable<Assembly> GetOurProjectAssemblies()
        {
            return AssemblyFinder.FindAssemblies(
              x => namespaces.Contains(x.FullName.Split(".").First())
           );
        }

When debugging BaseLine source code, I found that the Topological Sort using the Visitor Pattern takes too much time.

Another performance issue, the filter is applied until the end of the process. If the filter were applied at the beginning the number of the assemblies will drop drastically and the process will be fast.

Thank you,

jeremydmiller commented 4 years ago

Fixed by #230