Skip to content

Instantly share code, notes, and snippets.

@akshaymohite
Created October 26, 2017 12:11
Show Gist options
  • Save akshaymohite/246973a71d39c9fc606cd3f76d2114f5 to your computer and use it in GitHub Desktop.
Save akshaymohite/246973a71d39c9fc606cd3f76d2114f5 to your computer and use it in GitHub Desktop.
faker-vs-raw-random-approach
2.4.0 :029 > Benchmark.ips do |benchmark|
2.4.0 :030 > benchmark.report('faker approach') { Faker::Number.number(6) }
2.4.0 :031?> benchmark.report('raw random approach') { rand(100000..999999).to_s }
2.4.0 :032?> end
Warming up --------------------------------------
faker approach 28.347k i/100ms
raw random approach 159.529k i/100ms
Calculating -------------------------------------
faker approach 315.433k (± 4.0%) i/s - 1.587M in 5.040671s
raw random approach 2.981M (± 7.0%) i/s - 14.836M in 5.002986s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment