Class: Viiite::BDB::Cached::Proxy

Inherits:
Viiite::Benchmark show all
Includes:
Alf::Iterator
Defined in:
lib/viiite/bdb/cached.rb

Instance Attribute Summary

Attributes inherited from Viiite::Benchmark

#definition

Instance Method Summary collapse

Methods inherited from Viiite::Benchmark

new

Methods included from Viiite::Benchmark::Runner

#range_over, #report, #variation_point, #with

Constructor Details

#initialize(benchmark, cache_file, cache_mode) ⇒ Proxy

Returns a new instance of Proxy.



42
43
44
45
46
47
# File 'lib/viiite/bdb/cached.rb', line 42

def initialize(benchmark, cache_file, cache_mode)
  @benchmark  = benchmark
  @cache_file = cache_file
  @cache_mode = cache_mode
  super(@benchmark)
end

Instance Method Details

#eachObject



49
50
51
52
53
54
55
56
57
# File 'lib/viiite/bdb/cached.rb', line 49

def each
  FileUtils.mkdir_p(File.dirname(@cache_file))
  File.open(@cache_file, @cache_mode) do |io|
    @benchmark.each do |tuple|
      io << Alf::Tools.to_ruby_literal(tuple) << "\n"
      yield(tuple)
    end
  end
end