Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
to_money.format
[6] pry(main)> Benchmark.ips do |x|
[6] pry(main)* x.report("n2c") { number_to_currency(amount) }
[6] pry(main)* x.report("Money") { amount.to_money.format }
[6] pry(main)* x.compare!
[6] pry(main)* end
Warming up --------------------------------------
n2c 1.024k i/100ms
Money 2.076k i/100ms
Calculating -------------------------------------
n2c 9.718k (± 7.7%) i/s - 49.152k in 5.089582s
Money 18.109k (±16.7%) i/s - 89.268k in 5.108446s
Comparison:
Money: 18108.6 i/s
n2c: 9717.6 i/s - 1.86x (± 0.00) slower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment