val Now = new Properties.Double("now") def now(props: Properties.T): Double = Now.unapply(props).get
/* memory status */
val Heap_Size = new Properties.Long("size_heap") val Heap_Free = new Properties.Long("size_heap_free_last_GC") val GC_Percent = new Properties.Int("GC_percent")
val ml_statistics = ml_statistics0.sortBy(now) val time_start = if (ml_statistics.isEmpty) 0.0 else now(ml_statistics.head) val duration = if (ml_statistics.isEmpty) 0.0 else now(ml_statistics.last) - time_start
val fields =
SortedSet.empty[String] ++
(for {
props <- ml_statistics.iterator
(x, _) <- props.iterator if x != Now.name && domain(x) } yield x)
val content = { var last_edge = Map.empty[String, (Double, Double, Double)] val result = new mutable.ListBuffer[ML_Statistics.Entry] for (props <- ml_statistics) { val time = now(props) - time_start
val data =
SortedMap.empty[String, Double] ++
(for {
(x, y) <- props.iterator ++ speeds.iterator if x != Now.name && domain(x)
z = java.lang.Double.parseDouble(y) if z != 0.0
} yield { (x.intern, z) })
result += ML_Statistics.Entry(time, data)
}
result.toList
}
new ML_Statistics(heading, fields, content, time_start, duration)
}
}
finalclass ML_Statistics private( val heading: String, val fields: Set[String], val content: List[ML_Statistics.Entry], val time_start: Double, val duration: Double
) { overridedef toString: String = if (content.isEmpty) "ML_Statistics.empty" else"ML_Statistics(length = " + content.length + ", fields = " + fields.size + ")"
/* content */
def maximum(field: String): Double =
content.foldLeft(0.0) { case (m, e) => m max e.get(field) }
def average(field: String): Double = {
@tailrec def sum(t0: Double, list: List[ML_Statistics.Entry], acc: Double): Double =
list match { case Nil => acc case e :: es => val t = e.time
sum(t, es, (t - t0) * e.get(field) + acc)
}
content match { case Nil => 0.0 case List(e) => e.get(field) case e :: es => sum(e.time, es, 0.0) / duration
}
}
/* charts */
def update_data(data: XYSeriesCollection, selected_fields: List[String]): Unit = {
data.removeAllSeries() for (field <- selected_fields) { val series = new XYSeries(field)
content.foreach(e => series.add(e.time, ML_Statistics.field_scale(field, e.get(field))))
data.addSeries(series)
}
}
def chart(title: String, selected_fields: List[String]): JFreeChart = { val data = new XYSeriesCollection
update_data(data, selected_fields)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.