nitc :: FloatMetric
Used sor summarization
nitc :: FloatMetric :: _values_cache
FloatMetric
uses a Map to store values in intern.
nitc :: FloatMetric :: defaultinit
nitc :: FloatMetric :: values_cache
FloatMetric
uses a Map to store values in intern.
nitc :: FloatMetric :: values_cache=
FloatMetric
uses a Map to store values in intern.
nitc $ FloatMetric :: SELF
Type of this instance, automatically specialized in every classnitc $ FloatMetric :: above_threshold
The set of element above the thresholdnitc :: api_metrics $ FloatMetric :: core_serialize_to
Actual serialization ofself
to serializer
nitc $ FloatMetric :: to_console
Pretty print the metric results in consolenitc :: FloatMetric :: _values_cache
FloatMetric
uses a Map to store values in intern.
nitc :: Metric :: above_threshold
The set of element above the thresholdserialization :: 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 :: Metric :: defaultinit
nitc :: FloatMetric :: defaultinit
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
nitc :: Metric :: has_element
Does the element have a value for this metric?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 :: Metric :: to_console
Pretty print the metric results in consoleserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
nitc :: FloatMetric :: values_cache
FloatMetric
uses a Map to store values in intern.
nitc :: FloatMetric :: values_cache=
FloatMetric
uses a Map to store values in intern.
Serializer::serialize
# A Metric that collects float datas
#
# Used sor summarization
class FloatMetric
super Metric
redef type VAL: Float
# `FloatMetric` uses a Map to store values in intern.
protected var values_cache = new HashMap[ELM, VAL]
redef fun values do return values_cache
redef fun clear do values_cache.clear
redef fun sum do
var sum = 0.0
for v in values.values do
if v.is_nan then continue
sum += v
end
return sum
end
redef fun max do
assert not values.is_empty
var max: nullable Float = null
var elem: nullable ELM = null
for e, v in values do
if max == null or v > max then
max = v
elem = e
end
end
return elem.as(not null)
end
redef fun min do
assert not values.is_empty
var min: nullable Float = null
var elem: nullable ELM = null
for e, v in values do
if min == null or v < min then
min = v
elem = e
end
end
return elem.as(not null)
end
redef fun avg do
if values.is_empty then return 0.0
return sum / values.length.to_f
end
redef fun std_dev do
var sum = 0.0
for value in values.values do
if value.is_nan then continue
sum += (value - avg).pow(2.to_f)
end
return (sum / values.length.to_f).sqrt
end
redef fun above_threshold do
var above = new HashSet[ELM]
var threshold = threshold
for element, value in values do
if value > threshold then above.add(element)
end
return above
end
redef fun to_console(indent, colors) do
super
if colors then
print "{"\t" * indent} sum: {sum}".light_gray
else
print "{"\t" * indent} sum: {sum}"
end
end
end
src/metrics/metrics_base.nit:287,1--369,3
redef class FloatMetric
redef fun core_serialize_to(v) do
super
if values.not_empty then v.serialize_attribute("sum", sum)
end
end
src/doc/api/api_metrics.nit:182,1--187,3