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

Taking too much time to generate data when it exceeds 10K records. Also bogus data repeats. #357

Closed
mubina-hussain opened this issue Feb 10, 2021 · 1 comment
Labels

Comments

@mubina-hussain
Copy link

Version Information

Software Version(s)
Bogus NuGet Package 32.0.2
.NET Core?
.NET Full Framework? 4.6
Windows OS? Windows 10
Linux OS?
Visual Studio? Microsoft Visual Studio Professional 2019 Version 16.8.3

What locale are you using with Bogus?

english

What's the problem?

Taking too much time when the amount of data increases

What possible solutions have you considered?

Dont really know any solution since its an inbuilt thing

Do you have sample code to show what you're trying to do?

image

(Please be complete. Provide all code necessary to run your example in LINQPad.)
(The more complete code examples are, the more accurate answers will be.)
(https://www.linqpad.net)

@bchavez
Copy link
Owner

bchavez commented Feb 11, 2021

Hi @mubina-hussain,

Thank you for posting an issue.

The short summary is, eventually all data will repeat. You'll have to define what uniqueness means to your application. Second, I'm not able to debug a screenshot of the posted code. So my help will be limited only to pointing out a few things you'll want to look into:

  • Avoid using .RuleFor( ___ , z => z.Person....).

  • Try commenting out various rules and see if you notice any improvement in performance. Most likely, the problem is the work Bogus is being asked to do with the lambdas (ie: _ => doWork...).

    For example, suppose we are creating multiple users using bcrypt to produce passwords for user accounts. The bcrypt hashing process to produce passwords will be super slow if you include it in a Bogus' rule as shown below:
    .RuleFor( user => user.Password, f => CreateBcryptPassword(...)); // bcrypt is very slow.

    One (or several) of the rules in the screenshot will most likely be the cause of the slowness; you'll have to investigate. Also, running the code through a profiler could help.

  • Check if the code is making any database calls or making calls to an external service. These kinds of things usually slow down Bogus too.

I'm going to close the issue, but feel free to carry on the conversation if you have any other questions, please feel free to ask and I'll be happy to help. Let me know if you find the issue.

Also, here are other similar issues that may help you find a solution:

Thanks,
Brian

@bchavez bchavez closed this as completed Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants