nickdodd79 / AutoBogus

A C# library complementing the Bogus generator by adding auto creation and population capabilities.
MIT License
431 stars 50 forks source link

[Bug/Question] Large XML-mapping object times out #47

Closed frankhaugen closed 3 years ago

frankhaugen commented 3 years ago

I have an object/model/class that is generated with XSD from the UBL xsd for Invoice 2.1, (the generated file is 54'000 -ish lines, (or 1'200 individual classes after ReSharper have done it's magic).

I want to fake the object dynamically, because I don't want to do it manually, but my tests just times out, (using XUnit). If I use just the Faker from bogus it takes no time, but then it's basically useless unless I have hundreds of rules, making it easier to make manual fakes.

I really want to us AutoFaker for this as I love this tool, but it fails to work in this case. Is this a bug or is there some way to make this happen?

nickdodd79 commented 3 years ago

Hi @frankhaugen

Unfortunately AutoBogus does have some performance issues when working with large and certain recursive object graphs. It is mainly due to the reflection involved in generating instance. I have been working on some caching strategies to speed things up, but it is still a WIP and due to other commitments, finding a lengthy amount of time to work on it is difficult.

I will continue to solve this issue, so watch this space for updates.

Nick.

frankhaugen commented 3 years ago

@nickdodd79 okay, thanks for the explanation :-)

nickdodd79 commented 3 years ago

Hey @frankhaugen

A performance improvement has just been added to v2.13.0. Can you give it a run with your use case and see if it improves anything. You will need to use the WithTreeDepth config handler.

Nick.

frankhaugen commented 3 years ago

@nickdodd79

With a treedepth of four it took 8 seconds, 5 timed out at 30 seconds: image

I'm happy 👍