It purpose is to be extended with a metric collect service
nitc :: MetricSet :: defaultinit
nitc :: MetricSet :: to_console
Pretty print the resuls in consolenitc :: api_metrics $ MetricSet :: core_serialize_to
Actual serialization ofself
to serializer
serialization :: Serializable :: accept_inspect_serializer_core
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 :: Object :: defaultinit
nitc :: MetricSet :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
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.
serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).serialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
nitc :: MetricSet :: to_console
Pretty print the resuls in consoleserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
Serializer::serialize
# A MetricSet is a metric holder
#
# It purpose is to be extended with a metric collect service
class MetricSet
# Type of element measured by this `MetricSet`.
type ELM: Object
# Metrics to compute
var metrics: Set[Metric] = new HashSet[Metric]
# Add a metric to the set
fun register(metrics: Metric...) do for metric in metrics do self.metrics.add(metric)
# Clear all results for all metrics
fun clear do for metric in metrics do metric.clear
# Collect all metrics for this set of class
fun collect(elements: Set[ELM]) do
for metric in metrics do metric.collect(elements)
end
# Pretty print the resuls in console
fun to_console(indent: Int, colors: Bool) do
for metric in metrics do metric.to_console(indent, colors)
end
# Export the metric set in CSV format
fun to_csv: CsvDocument do
var csv = new CsvDocument
csv.separator = ';'
# set csv headers
csv.header.add("entry")
for metric in metrics do csv.header.add(metric.name)
# collect all entries to merge metric results
var entries = new HashSet[ELM]
for metric in metrics do
for entry in metric.values.keys do entries.add(entry)
end
# collect results
for entry in entries do
var line = [entry.to_s]
for metric in metrics do
if metric.has_element(entry) then
line.add(metric[entry].to_s)
else
line.add("n/a")
end
end
csv.records.add(line)
end
return csv
end
end
src/metrics/metrics_base.nit:371,1--427,3
redef class MetricSet
super Serializable
redef fun core_serialize_to(v) do
for metric in metrics do
v.serialize_attribute(metric.name, metric)
end
end
end
src/doc/api/api_metrics.nit:152,1--160,3