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

Add a benchmark to retrieve a random number from a specific range #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yogodoshi
Copy link

I just discovered the :random.uniform/1 function so I tested it against the Enum.random/1 that I was using before.

I've used the latest Elixir version though as I thought there was no reason to use the older one, I assumed it just hasn't been updated because no one touched the code since the new version got released.

I've followed the "CONTRIBUTING" guideline but let me know if you want me to change anything :)

@@ -593,6 +593,74 @@ flat_map 13.64 MB - 1.67x memory usage
**All measurements for memory usage were the same**
```

#### Generating a random number with `Enum.rand/1` and `:random.unform/1` [code](code/general/enum_random_vs_rand_uniform.exs)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about other ways of generating a random number, like just random:uniform() without the limit? If we're looking at just a random number generator, there are a lot of ways to go about that that don't specify the range the number must be in. For example, there's also Erlang's rand module, which uses a different algorithm than random but isn't truly random enough for stuff like cryptography, but might be random enough for most other uses.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I needed was to generate a random number among a range. I should've explicitly explained that in the description.

What do you want to do? I can expand this, change the description to try explain that it is generating a number between a range/limit, or just close the PR if you think it is an example that it is too broad. No hard feelings :)

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

Successfully merging this pull request may close these issues.

2 participants