Sha256: 66e60e4056475d2e8de3081969daf96e56239ed26bbec0d10d9655385dc330c2

Contents?: true

Size: 1.11 KB

Versions: 24

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

$: << '.'
$: << File.join(File.dirname(__FILE__), "../lib")
$: << File.join(File.dirname(__FILE__), "../ext")

require 'oj'

filename = 'tmp.json'
File.open(filename, "w") { |f|
  cnt = 0
  f.puts('{')
  ('a'..'z').each { |a|
    ('a'..'z').each { |b|
      ('a'..'z').each { |c|
	('a'..'z').each { |d|
	  f.puts(%|"#{a}#{b}#{c}#{d}":#{cnt},|)
	  cnt += 1
	}
      }
    }
  }
  f.puts('"_last":0}')
}

def mem
  `ps -o rss= -p #{$$}`.to_i
end

Oj.default_options = { mode: :strict, cache_keys: false, cache_str: -1 }
start = Time.now
Oj.load_file('tmp.json')
dur = Time.now - start
GC.start
puts "no cache duration: #{dur} @ #{mem}"

Oj.default_options = { cache_keys: true }
start = Time.now
Oj.load_file('tmp.json')
dur = Time.now - start
GC.start
puts "initial cache duration: #{dur} @ #{mem}"

start = Time.now
Oj.load_file('tmp.json')
dur = Time.now - start
GC.start
puts "second cache duration: #{dur} @ #{mem}"

10.times{ GC.start }
start = Time.now
Oj.load_file('tmp.json')
dur = Time.now - start
GC.start
puts "after several GCs cache duration: #{dur} @ #{mem}"

# TBD check memory use

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
oj-3.14.2 test/perf_once.rb
oj-3.14.1 test/perf_once.rb
oj-3.14.0 test/perf_once.rb
oj-3.13.23 test/perf_once.rb
oj-3.13.22 test/perf_once.rb
oj-3.13.21 test/perf_once.rb
oj-3.13.20 test/perf_once.rb
oj-3.13.19 test/perf_once.rb
oj-3.13.18 test/perf_once.rb
oj-3.13.17 test/perf_once.rb
oj-3.13.16 test/perf_once.rb
oj-3.13.15 test/perf_once.rb
oj-3.13.14 test/perf_once.rb
oj-3.13.13 test/perf_once.rb
oj-3.13.12 test/perf_once.rb
oj-3.13.11 test/perf_once.rb
oj-3.13.10 test/perf_once.rb
oj-3.13.9 test/perf_once.rb
oj-3.13.8 test/perf_once.rb
oj-3.13.7 test/perf_once.rb