Skip to content

Performance regression in 'IsTypedBy' #674

Description

@andreinovikovsiemens

Starting with version 6.0.442, calling 'IsTypedBy' for IIfcElement takes significantly more time when working with relatively large models.

I prepared simple projects with similar console applications, but different versions of xbim as dependencies.

IsTypedByRegressionCheck.zip

How to reproduce:

  1. Download and open the attached solution in Visual Studio.
  2. Set Example_5_1_341 as the startup project.
  3. In the project settings (Debug section), add the path to the IFC file to the command line arguments. (e.g., NBU_MedicalClinic_Eng-MEP.ifc from this link).
  4. Run the project.
  5. Set Example_6_0_442 as the startup project.
  6. Add the same IFC file path to the command line arguments for this project.
  7. Run the project.
  8. Compare the results.
    Example output:
Hello xbim!
Example_5_1_341, file name: NBU_MedicalClinic_Eng-MEP.ifc
ifc store ready
total elements count: 16012
elements with type count: 16012
open store time: 12.2334502
process elements time: 0.06461
Hello xbim!
Example_6_0_442, file name: NBU_MedicalClinic_Eng-MEP.ifc
ifc store ready
total elements count: 16012
elements with type count: 16012
open store time: 34.6255213
process elements time: 14.0791487

As of my results from my laptop it was 0.06461 s in project with dependency on xbim 5.1.341 against 14.0791487 s in project with dependency on xbim 6.0.442
As of my tests with updated xbim - newer versions of xbim performing in relative same time as 6.0.442


Here is code from attached project just in case

public class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello xbim!");
        Console.WriteLine(string.Format("Example_5_1_341, file name: {0}", Path.GetFileName(args[0])));

        string filePath = args[0];

        Stopwatch openStoreStopwatch = new Stopwatch();
        Stopwatch processElementsStopwatch = new Stopwatch();
        openStoreStopwatch.Start();
        using (IfcStore ifcStore = IfcStore.Open(args[0]))
        {
            openStoreStopwatch.Stop();
            Console.WriteLine("ifc store ready");
            using (var inverseCache = ifcStore.BeginInverseCaching())
            {
                processElementsStopwatch.Start();
                var elements = ifcStore.Instances.OfType<IIfcElement>().ToList();

                int typedElementsCount = 0;
                Console.WriteLine(string.Format("total elements count: {0}", elements.Count));
                foreach (var element in elements)
                {
                    var typedDefault = element.IsTypedBy.FirstOrDefault();
                    if (typedDefault == null || typedDefault.RelatingType == null 
                        || typedDefault.RelatingType.Name == null || !typedDefault.RelatingType.Name.HasValue)
                    {
                        continue;
                    }

                    typedElementsCount++;
                }
                processElementsStopwatch.Stop();
                Console.WriteLine(string.Format("elements with type count: {0}", typedElementsCount));
            }
        }

        Console.WriteLine(string.Format("open store time: {0}", openStoreStopwatch.Elapsed.TotalSeconds.ToString()));
        Console.WriteLine(string.Format("process elements time: {0}", processElementsStopwatch.Elapsed.TotalSeconds.ToString()));

    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions