Sha256: 4ac8f1bf4c873cf49d6cba54460c132b49101837ea712990c73dbb37c90cf5c2

Contents?: true

Size: 471 Bytes

Versions: 1

Compression:

Stored size: 471 Bytes

Contents

require 'dotcfg'
require 'benchmark/ips'

def new_filename
  begin
    Dir::Tmpname.make_tmpname('/tmp/dotcfg', nil)
  rescue
    ['/tmp/dotcfg', rand(9**9)].join('-')
  end
end

fn = new_filename
dc = DotCfg.new(fn)
dc['foo'] = 0

Benchmark.ips do |b|
  b.config time: 5, warmup: 0.5
  b.report("write #{fn}") {
    dc['foo'] += 1
    dc.save
  }

  b.report("rewrite #{fn}") {
    dc.load
    dc['foo'] += 1
    dc.save
  }

  b.compare!
end

p dc.to_h

File.unlink fn

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dotcfg-1.0.2.1 test/bench/dotcfg.rb