xBimTeam / XbimSamples

Code examples. Most of these examples are described and explained on our website.
https://xbimteam.github.io/
33 stars 31 forks source link

Linq vs foreach loop - Quite weird result based on your expectation #12

Open liszto opened 6 years ago

liszto commented 6 years ago

I tried to execute your code from BasicExample on LinqExample.cs and first your comment triggered me cause for me Linq has always been slower than any other much basic stuff like a foreach. Cause behind all the Linq process, there is only some foreach loop + some useless allocation that are avoided from a custom foreach iteration.

So I decided to execute your basic example in 2 differents cases and here are my results : VS2017 / .NET 4.6.1 on SampleHouse.ifc file : image

VS2017 / .NET 4.6.1 on Lakeside.ifc : image

I tried in Unity too but it seems to be altered by my issue with the IfcStore.Open method which take a lot of time but even on Unity the difference is roughly one seconds between both methods for a result of 15sec with Linq and 16 without Linq which is odd.

Have you any proof of this Linq 4.5x slower ?