Skip to content

Instantly share code, notes, and snippets.

@rmm5t
Last active February 1, 2019 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmm5t/9ee58580f009afd82f6f to your computer and use it in GitHub Desktop.
Save rmm5t/9ee58580f009afd82f6f to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'time'
n = 1_000_000
t = Time.new.utc
Benchmark.bmbm do |x|
x.report("unix epoch") { n.times { t.to_i.to_s } }
x.report("iso 8601 ") { n.times { t.iso8601 } }
end
# Ruby 2.3.0
# user system total real
# unix epoch 0.310000 0.010000 0.320000 ( 0.322514)
# iso 8601 0.960000 0.000000 0.960000 ( 0.976739)
# JRuby 1.7.23
# user system total real
# unix epoch 0.130000 0.000000 0.130000 ( 0.100000)
# iso 8601 1.350000 0.010000 1.360000 ( 1.027000)
# JRuby 9.0.4.0
# user system total real
# unix epoch 0.100000 0.000000 0.100000 ( 0.102591)
# iso 8601 3.800000 0.030000 3.830000 ( 3.562767)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment