Class: Ruptr::TimingCache::Store
- Inherits:
-
Object
- Object
- Ruptr::TimingCache::Store
show all
- Includes:
- Sink
- Defined in:
- lib/ruptr/timing_cache.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Sink
#begin_case, #begin_group, #finish_group, #finish_plan, #submit_case, #submit_group, #submit_plan
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
38
39
40
|
# File 'lib/ruptr/timing_cache.rb', line 38
def initialize
@current = {}
end
|
Class Method Details
.load ⇒ Object
36
|
# File 'lib/ruptr/timing_cache.rb', line 36
def self.load(...) = new.tap { |o| o.load(...) }
|
Instance Method Details
#[](te) ⇒ Object
86
|
# File 'lib/ruptr/timing_cache.rb', line 86
def [](te) = @current[te] || Float::INFINITY
|
#begin_plan(_) ⇒ Object
90
91
92
|
# File 'lib/ruptr/timing_cache.rb', line 90
def begin_plan(_)
@updated = {}
end
|
#dump(_ts, path, replace: true) ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/ruptr/timing_cache.rb', line 77
def dump(_ts, path, replace: true)
h = replace ? {} : load_hashed(path)
@updated.each_pair do |te, time|
k = te_hash(te)
h[k] = [h[k] || 0, time].max
end
dump_hashed(path, h)
end
|
#finish_case(tc, tr) ⇒ Object
94
95
96
97
|
# File 'lib/ruptr/timing_cache.rb', line 94
def finish_case(tc, tr)
time = tr.processor_time
@updated[tc] = time if time
end
|
#load(ts, path) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/ruptr/timing_cache.rb', line 53
def load(ts, path)
h = load_hashed(path)
traverse = lambda do |tg|
total_time = 0
tg.each_test_case do |tc|
time = h[te_hash(tc)] or next
@current[tc] = time
total_time += time
end
tg.each_test_subgroup do |tg|
total_time += traverse.call(tg)
end
@current[tg] = total_time
end
traverse.call(ts)
end
|