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

Browser is endless loading while generating string numeric with big range #2576

Closed
7 of 10 tasks
pschaub opened this issue Dec 12, 2023 · 6 comments
Closed
7 of 10 tasks
Labels
question Further information is requested

Comments

@pschaub
Copy link

pschaub commented Dec 12, 2023

Pre-Checks

Describe the bug

I tried to use faker.string.numeric({ length: { min: 10000000, max: 99999999 }) but my browser was hanging. I've tested it in Google Chrome 120.0.6099.71 and Microsoft Edge 120.0.2210.61.

I guess that this is a performance issue in the used algorithm, so that it doesn't scale well with huge numbers.

Minimal reproduction code

https://stackblitz.com/edit/faker-js-demo-gbihnb?file=index.ts

Additional Context

No response

Environment Info

System:
    OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12600K
    Memory: 13.74 GB / 31.09 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v20.10.0/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.10.0/bin/npm
  Browsers:
    Chrome: 120.0.6099.71

Which module system do you use?

  • CJS
  • ESM

Used Package Manager

npm

@pschaub pschaub added c: bug Something isn't working s: pending triage Pending Triage labels Dec 12, 2023
@pschaub
Copy link
Author

pschaub commented Dec 12, 2023

I got something mixed up here: the function faker.string.numeric({ length: { min: 10000000, max: 99999999 }) tries to generate a numeric string with a random character length between 10000000-99999999, instead of numbers in the range between 10000000-99999999.

I therefore think that nothing can be solved here within the library. I am therefore closing the ticket.

@pschaub pschaub closed this as completed Dec 12, 2023
@ST-DDT
Copy link
Member

ST-DDT commented Dec 12, 2023

If you haven't found it yet, faker.number.int() is probably what you are searching for.

@ST-DDT ST-DDT added question Further information is requested and removed c: bug Something isn't working s: pending triage Pending Triage labels Dec 12, 2023
@xDivisionByZerox
Copy link
Member

Even with the "issue" resolved, this sounds like a performance issue for me. Am I wrong with that assumption?

@ST-DDT
Copy link
Member

ST-DDT commented Dec 12, 2023

One faker.string.numeric({ length: { min: 10_000_000, max: 99_999_999 }) call takes ~20seconds for me.
That's ~2_500 (50kk/20k) chars per millisecond (ms). IMO that is acceptable.

@ST-DDT
Copy link
Member

ST-DDT commented Dec 12, 2023

What is your expectation?

@pschaub
Copy link
Author

pschaub commented Dec 15, 2023

If you haven't found it yet, faker.number.int() is probably what you are searching for.

I was looking for a string representation. But using faker.number.int() and afterwards converting it into a string works too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants