Class: Caliper::Stats::StatisticsMap
- Inherits:
-
Hash
- Object
- Hash
- Caliper::Stats::StatisticsMap
- Defined in:
- lib/caliper/stats/statistics_map.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#ensure(key) ⇒ Object
Make sure the key value exists in the hashmap Add the key value if not found before.
-
#to_s ⇒ Object
the pretty formatted string output.
-
#update(operation, val) ⇒ Object
Insert a new Statistic object if there is no key with specified value Otherwise, update the hashed value with the value provided.
Instance Method Details
#ensure(key) ⇒ Object
Make sure the key value exists in the hashmap Add the key value if not found before
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/caliper/stats/statistics_map.rb', line 27 def ensure(key) # returns key-ed vale if key exists if has_key?(key) return fetch(key) end # else insert the key statistic = Statistic.new() this.put(key, statistic) return statistic end |
#to_s ⇒ Object
the pretty formatted string output
49 50 51 52 53 54 55 56 |
# File 'lib/caliper/stats/statistics_map.rb', line 49 def to_s r_string = "\r-------- Caliper Java Statistics --------\r"; hash.each do |key, value| statistics = value; r_string = r_string + "%s : %s\r", key, statistic.to_s() end return r_string end |
#update(operation, val) ⇒ Object
Insert a new Statistic object if there is no key with specified value Otherwise, update the hashed value with the value provided
41 42 43 44 45 46 |
# File 'lib/caliper/stats/statistics_map.rb', line 41 def update(operation, val) if (!has_key?(operation)) this.put(operation, Statistic.new()) end this.fetch(operation).update(val) end |