Created
June 4, 2014 22:27
-
-
Save warmwaffles/8027ea685c1d67d97046 to your computer and use it in GitHub Desktop.
Benchmark of the ruby Time class.
This file contains hidden or 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
| require 'time' | |
| require 'benchmark' | |
| max = (ARGV.shift || 100000).to_i | |
| puts "# of iterations = #{max}" | |
| Benchmark::bm(20) do |x| | |
| x.report("Time.parse") do | |
| (0..max).each do | |
| Time.parse("2010-08-15 00:00:00 UTC").to_i | |
| end | |
| end | |
| x.report("Time.utc") do | |
| (0..max).each do | |
| Time.utc(2010, 8, 15).to_i | |
| end | |
| end | |
| end |
Author
Author
On an Arm7
# of iterations = 100000
user system total real
Time.parse 45.760000 4.230000 49.990000 ( 50.027684)
Time.utc 3.440000 2.720000 6.160000 ( 6.157313)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On a Core i7