LoginSignup
15

More than 5 years have passed since last update.

FakerとFFakerの比較

Posted at

Rubyのテスト時に使ったりする偽データ生成ライブラリにfakerというのがあるのですが、このfaker、じつはfast fakerという実装があり、こちらの方が高速と言われています。

気になったので雑に計測してみました。

def bench1000
  start = Time.now  
  1000.times{yield}
  finish = Time.now  
  puts "Time: #{(finish - start).to_f}"  
end

とりあえず1000回で計測してみた。

require 'faker'
bench1000{Faker::Name.name}
# => Time: 0.186539

ffaker

require 'ffaker'
bench1000{Faker::Name.name}
# => Time: 0.009986

雑な計測ですが、明らかに早いですね、ffaker。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15