Skip to content

Instantly share code, notes, and snippets.

@odayvhl
Created March 12, 2019 16:09
Show Gist options
  • Save odayvhl/bc363cb07bac5e27cca4cbbd966a7cd4 to your computer and use it in GitHub Desktop.
Save odayvhl/bc363cb07bac5e27cca4cbbd966a7cd4 to your computer and use it in GitHub Desktop.
Test the time for each cost from 10 to 20 in bcrypt
require 'bcrypt'
require 'time'
puts "cost: 10"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>10)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 11"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>11)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 12"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>12)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 13"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>13)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 14"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>14)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 15"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>15)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 16"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>16)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 17"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>17)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 18"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>18)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 19"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>19)
end_time = Time.now
puts "time: #{end_time - start_time}"
puts "cost: 20"
start_time = Time.now
password = BCrypt::Password.create("Password", :cost=>20)
end_time = Time.now
puts "time: #{end_time - start_time}"
@odayvhl
Copy link
Author

odayvhl commented Mar 12, 2019

Test run on my desktop

cost: 10
time: 0.057958305
cost: 11
time: 0.115234043
cost: 12
time: 0.225779151
cost: 13
time: 0.447198155
cost: 14
time: 0.898556277
cost: 15
time: 1.800816733
cost: 16
time: 3.594120408
cost: 17
time: 7.213717422
cost: 18
time: 14.367128511
cost: 19
time: 28.656331608
cost: 20
time: 57.390706443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment