Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 86 lines (58 sloc) 2.652 kb

ffaker

Fast Faker == Faker refactored, cleaner and faster.

Faker

A port of Perl's Data::Faker library that generates fake data.

Usage

require 'ffaker'

Faker::Name.name => "Christophe Bartell"

Faker::Internet.email => "kirsten.greenholt@corkeryfisher.info"

Ffaker / Faker ==

This version of the gem was modified by me (Emmanuel Oga) cause I was so annoyed on several ineficiencies on the original gem.

And because I coult not find the original author on github (and I don't feel like working with the arcane rubyforge+svn tools) I just realised this gem using a different name.

The only difference in usage is that you need to gem install ffaker, and require 'ffaker', instead of the previous “faker” with one f.

The API is pretty much the same. Fork/ping me if you feel like adding more goodies to it.

Faster??? does it really matter ??? ==

While it may seem like the speed of good'ol faker is not such a big deal, I really disliked the previous code base.

Speed came as a result of having better code in place. In any case getting a few more cycles here and there is not bad, specially since I had fun while doing the refactoring :).

Here are some benchmarks (yeah everybody love benchmarks!)

$ cat scripts/benchmark.rb

# ...
N = 10_000

Benchmark.bm do |rep|
  rep.report("generating #{ N } names") do
    N.times do
      Faker::Name.name
    end
  end
end
  • ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux],

    MBARI 0x6770, Ruby Enterprise Edition 2009.10
    
         user     system      total        real

    Faker 9.240000 0.020000 9.260000 ( 9.297381) Fast Faker 0.060000 0.000000 0.060000 ( 0.109047)

  • ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]

    user     system      total        real

Faker 74.980000 0.110000 75.090000 ( 75.881142) Fast Faker 0.050000 0.000000 0.050000 ( 0.052292)

DISCLAIMER: I have no idea why I'm getting such bad numbers for traditional faker on 1.9, but I'm not making up this!!! Try it in your own machine, your milage may vary.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2010 Emmanuel Oga. See LICENSE for details. Copyright © 2007 Benjamin Curtis

Something went wrong with that request. Please try again.