performance_analysis :: PerfMap :: precision
Number of digits to the right of the decimal points in reports created byto_s
performance_analysis :: PerfMap :: precision=
Number of digits to the right of the decimal points in reports created byto_s
performance_analysis $ PerfMap :: SELF
Type of this instance, automatically specialized in every classperformance_analysis $ PerfMap :: provide_default_value
Called by the underling implementation of[]
to provide a default value when a key
has no value
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePackserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
core :: MapRead :: defaultinit
core :: HashMap :: defaultinit
core :: Map :: defaultinit
core :: Object :: defaultinit
core :: MapRead :: filter_keys
Return all elements ofkeys
that have a value.
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
core :: MapRead :: get_or_default
Get the item atkey
or return default
if not in map
core :: MapRead :: get_or_null
Get the item atkey
or null if key
is not in the map.
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: MapRead :: keys_sorted_by_values
Return an array of all keys sorted with their values usingcomparator
.
core :: MapRead :: lookup_all_values
Search all the values inpe.greaters
.
core :: MapRead :: lookup_values
Combine the values inpe.greaters
from the most smaller elements that have a value.
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: output_class_name
Display class name on stdout (debug only).performance_analysis :: PerfMap :: precision
Number of digits to the right of the decimal points in reports created byto_s
performance_analysis :: PerfMap :: precision=
Number of digits to the right of the decimal points in reports created byto_s
core :: MapRead :: provide_default_value
Called by the underling implementation of[]
to provide a default value when a key
has no value
serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
core :: MapRead :: to_map_comparator
A comparator that compares things with their values in self.serialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
core :: MapRead :: values_sorted_by_key
Return an array of all values sorted with their keys usingcomparator
.
# Collection of statistics on many events
class PerfMap
super HashMap[String, PerfEntry]
redef fun provide_default_value(key)
do
if not key isa String then return super
var ts = new PerfEntry(key)
self[key] = ts
return ts
end
# Number of digits to the right of the decimal points in reports created by `to_s`
#
# Defaults to 4.
var precision = 4 is writable
redef fun to_s
do
var prec = precision
var table = new Map[String, Array[String]]
for event, stats in self do
table[event] = [event,
stats.min.to_precision(prec),
stats.max.to_precision(prec),
stats.avg.to_precision(prec),
stats.sum.to_precision(prec),
stats.count.to_s]
end
var widths = [0] * 6
for event, row in table do
for i in row.length.times do
widths[i] = widths[i].max(row[i].length)
end
end
var s = "# {"Event".justify(widths[0], 0.0)} {"min".justify(widths[1], 0.5)} {"max".justify(widths[2], 0.5)} {"avg".justify(widths[3], 0.5)} {"sum".justify(widths[4], 0.5)} {"count".justify(widths[5], 0.5)}\n"
var sorted_events = table.keys.to_a
alpha_comparator.sort sorted_events
for event in sorted_events do
var row = table[event]
s += "*"
for c in row.length.times do
var cell = row[c]
s += " "
if c == 0 then
s += cell.justify(widths[c], 0.0, '.')
else s += cell.justify(widths[c], 1.0)
end
s += "\n"
end
return s
end
end
lib/performance_analysis/performance_analysis.nit:50,1--107,3