Class: XCCache::Cache::Cachemap
Instance Attribute Summary
#path, #raw
Instance Method Summary
collapse
#load, #save
#[], #[]=, #initialize, #load, #merge!, #save
Instance Method Details
#cache_data ⇒ Object
10
11
12
|
# File 'lib/xccache/cache/cachemap.rb', line 10
def cache_data
raw["cache"] ||= {}
end
|
#depgraph_data ⇒ Object
6
7
8
|
# File 'lib/xccache/cache/cachemap.rb', line 6
def depgraph_data
raw["depgraph"] ||= {}
end
|
#get_cache_data(type) ⇒ Object
51
52
53
|
# File 'lib/xccache/cache/cachemap.rb', line 51
def get_cache_data(type)
cache_data.select { |_, v| v == type }.keys
end
|
#manifest_data ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/xccache/cache/cachemap.rb', line 14
def manifest_data
raw["manifest"] ||= {
"targets" => {},
"deps" => {},
"macros" => {},
}
end
|
#missed ⇒ Object
26
27
28
|
# File 'lib/xccache/cache/cachemap.rb', line 26
def missed
get_cache_data(:missed)
end
|
#missed?(name) ⇒ Boolean
22
23
24
|
# File 'lib/xccache/cache/cachemap.rb', line 22
def missed?(name)
missed.include?(name)
end
|
#print_stats ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/xccache/cache/cachemap.rb', line 38
def print_stats
hit, missed, ignored = i[hit missed ignore].map { |type| get_cache_data(type) }
total_count = cache_data.count
UI.message " -------------------------------------------------------------------\n Cache stats\n \u2022 Hit (\#{hit.count}/\#{total_count}): \#{hit.to_s.green.dark}\n \u2022 Missed (\#{missed.count}/\#{total_count}): \#{missed.to_s.yellow.dark}\n \u2022 Ignored (\#{ignored.count}/\#{total_count}): \#{ignored.to_s.yellow.dark}\n -------------------------------------------------------------------\n DESC\nend\n"
|
#stats ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/xccache/cache/cachemap.rb', line 30
def stats
i[hit missed ignored].to_h do |type|
count, total_count = get_cache_data(type).count, cache_data.count
percent = total_count.positive? ? (count.to_f * 100 / total_count).round : 0
[type, "#{percent}% (#{count}/#{total_count})"]
end
end
|