Sha256: 6debb5cba0093285f063f353e95fdf455e4119381edda3de2b5a29a92bd2c54d
Contents?: true
Size: 1.07 KB
Versions: 15
Compression:
Stored size: 1.07 KB
Contents
#!/usr/bin/env ruby require 'benchmark' require 'timezone' def load_tz(timezone) Timezone.fetch(timezone) end puts 'Loading timezones' LOAD_ITERATIONS = 1_000 Benchmark.bm do |x| x.report('la') { LOAD_ITERATIONS.times { load_tz('America/Los_Angeles') } } x.report('hk') { LOAD_ITERATIONS.times { load_tz('Asia/Hong_Kong') } } end def calc_local(timezone) timezone.time(Time.utc(3000, 1, 1)) end puts 'Calculating LOCAL' LOCAL_ITERATIONS = 10_000 Benchmark.bm do |x| timezone = Timezone.fetch('America/Los_Angeles') x.report('la') { LOCAL_ITERATIONS.times { calc_local(timezone) } } timezone = Timezone.fetch('Asia/Hong_Kong') x.report('hk') { LOCAL_ITERATIONS.times { calc_local(timezone) } } end def calc_utc(timezone) timezone.local_to_utc(Time.utc(3000, 1, 1)) end puts 'Calculating UTC' UTC_ITERATIONS = 10_000 Benchmark.bm do |x| timezone = Timezone.fetch('America/Los_Angeles') x.report('la') { UTC_ITERATIONS.times { calc_utc(timezone) } } timezone = Timezone.fetch('Asia/Hong_Kong') x.report('hk') { UTC_ITERATIONS.times { calc_utc(timezone) } } end
Version data entries
15 entries across 15 versions & 1 rubygems