Created
August 6, 2021 19:43
-
-
Save scottjacobsen/ace4d5d4f47367f9a05aaf2bdc83bf35 to your computer and use it in GitHub Desktop.
to_money.format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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