src/Pure/ML/ml_statistics.scala
author wenzelm
Fri, 31 Aug 2018 22:25:58 +0200
changeset 68865 dd44e31ca2c6
parent 68129 b73678836f8e
child 69822 8c587dd44f51
permissions -rw-r--r--
support multiple inheritance of ML environments, with canonical merge order as in Context.begin_theory;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65477
64e61b0f6972 clarified directories;
wenzelm
parents: 65318
diff changeset
     1
/*  Title:      Pure/ML/ml_statistics.scala
50685
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     3
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     4
ML runtime statistics.
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     5
*/
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     6
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     7
package isabelle
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     8
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
     9
65858
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
    10
import scala.annotation.tailrec
51432
903be59d9665 simplified time_CPU and time_GC;
wenzelm
parents: 51240
diff changeset
    11
import scala.collection.mutable
50688
f02864682307 some support for ML statistics content interpretation;
wenzelm
parents: 50685
diff changeset
    12
import scala.collection.immutable.{SortedSet, SortedMap}
50691
20beafe66748 added standard_frames convenience;
wenzelm
parents: 50690
diff changeset
    13
import scala.swing.{Frame, Component}
50688
f02864682307 some support for ML statistics content interpretation;
wenzelm
parents: 50685
diff changeset
    14
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
    15
import org.jfree.data.xy.{XYSeries, XYSeriesCollection}
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
    16
import org.jfree.chart.{JFreeChart, ChartPanel, ChartFactory}
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
    17
import org.jfree.chart.plot.PlotOrientation
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
    18
50688
f02864682307 some support for ML statistics content interpretation;
wenzelm
parents: 50685
diff changeset
    19
50685
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
    20
object ML_Statistics
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
    21
{
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    22
  /* properties */
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    23
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    24
  val Now = new Properties.Double("now")
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    25
  def now(props: Properties.T): Double = Now.unapply(props).get
50697
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
    26
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    27
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    28
  /* heap */
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    29
65858
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
    30
  val HEAP_SIZE = "size_heap"
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
    31
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    32
  def heap_scale(x: Long): Long = x / 1024 / 1024
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    33
  def heap_scale(x: Double): Double = heap_scale(x.toLong).toLong
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    34
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    35
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    36
  /* standard fields */
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
    37
65864
1945fa8f0c39 simplified signature;
wenzelm
parents: 65858
diff changeset
    38
  type Fields = (String, List[String])
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    39
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    40
  val tasks_fields: Fields =
60610
f52b4b0c10c4 improved scheduling for urgent tasks, using farm of replacement threads (may lead to factor 2 overloading, but CPUs are usually hyperthreaded);
wenzelm
parents: 57869
diff changeset
    41
    ("Future tasks",
68129
b73678836f8e record total number of tasks;
wenzelm
parents: 67760
diff changeset
    42
      List("tasks_ready", "tasks_pending", "tasks_running", "tasks_passive",
b73678836f8e record total number of tasks;
wenzelm
parents: 67760
diff changeset
    43
        "tasks_urgent", "tasks_total"))
57869
9665f79a7181 improved monitor panel;
wenzelm
parents: 57612
diff changeset
    44
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    45
  val workers_fields: Fields =
57869
9665f79a7181 improved monitor panel;
wenzelm
parents: 57612
diff changeset
    46
    ("Worker threads", List("workers_total", "workers_active", "workers_waiting"))
9665f79a7181 improved monitor panel;
wenzelm
parents: 57612
diff changeset
    47
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    48
  val GC_fields: Fields =
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    49
    ("GCs", List("partial_GCs", "full_GCs"))
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    50
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    51
  val heap_fields: Fields =
65858
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
    52
    ("Heap", List(HEAP_SIZE, "size_allocation", "size_allocation_free",
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    53
      "size_heap_free_last_full_GC", "size_heap_free_last_GC"))
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    54
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    55
  val threads_fields: Fields =
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    56
    ("Threads", List("threads_total", "threads_in_ML", "threads_wait_condvar",
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    57
      "threads_wait_IO", "threads_wait_mutex", "threads_wait_signal"))
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    58
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    59
  val time_fields: Fields =
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    60
    ("Time", List("time_CPU", "time_GC"))
51432
903be59d9665 simplified time_CPU and time_GC;
wenzelm
parents: 51240
diff changeset
    61
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    62
  val speed_fields: Fields =
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
    63
    ("Speed", List("speed_CPU", "speed_GC"))
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
    64
65053
460f0fd2f77a clarified defaults;
wenzelm
parents: 65051
diff changeset
    65
460f0fd2f77a clarified defaults;
wenzelm
parents: 65051
diff changeset
    66
  val all_fields: List[Fields] =
57869
9665f79a7181 improved monitor panel;
wenzelm
parents: 57612
diff changeset
    67
    List(tasks_fields, workers_fields, GC_fields, heap_fields, threads_fields,
9665f79a7181 improved monitor panel;
wenzelm
parents: 57612
diff changeset
    68
      time_fields, speed_fields)
65053
460f0fd2f77a clarified defaults;
wenzelm
parents: 65051
diff changeset
    69
460f0fd2f77a clarified defaults;
wenzelm
parents: 65051
diff changeset
    70
  val main_fields: List[Fields] =
460f0fd2f77a clarified defaults;
wenzelm
parents: 65051
diff changeset
    71
    List(tasks_fields, workers_fields, heap_fields)
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    72
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    73
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    74
  /* content interpretation */
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    75
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    76
  final case class Entry(time: Double, data: Map[String, Double])
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    77
  {
65858
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
    78
    def get(field: String): Double = data.getOrElse(field, 0.0)
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    79
  }
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    80
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    81
  val empty: ML_Statistics = apply(Nil)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    82
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
    83
  def apply(ml_statistics: List[Properties.T], heading: String = "",
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
    84
    domain: String => Boolean = (key: String) => true): ML_Statistics =
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    85
  {
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    86
    require(ml_statistics.forall(props => Now.unapply(props).isDefined))
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    87
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    88
    val time_start = if (ml_statistics.isEmpty) 0.0 else now(ml_statistics.head)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    89
    val duration = if (ml_statistics.isEmpty) 0.0 else now(ml_statistics.last) - time_start
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    90
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    91
    val fields =
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    92
      SortedSet.empty[String] ++
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
    93
        (for {
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
    94
          props <- ml_statistics.iterator
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
    95
          (x, _) <- props.iterator
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
    96
          if x != Now.name && domain(x) } yield x)
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    97
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    98
    val content =
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
    99
    {
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   100
      var last_edge = Map.empty[String, (Double, Double, Double)]
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   101
      val result = new mutable.ListBuffer[ML_Statistics.Entry]
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   102
      for (props <- ml_statistics) {
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   103
        val time = now(props) - time_start
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   104
        require(time >= 0.0)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   105
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   106
        // rising edges -- relative speed
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   107
        val speeds =
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   108
          (for {
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   109
            (key, value) <- props.iterator
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   110
            a <- Library.try_unprefix("time", key)
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   111
            b = "speed" + a if domain(b)
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   112
          }
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   113
          yield {
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   114
            val (x0, y0, s0) = last_edge.getOrElse(a, (0.0, 0.0, 0.0))
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   115
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   116
            val x1 = time
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   117
            val y1 = java.lang.Double.parseDouble(value)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   118
            val s1 = if (x1 == x0) 0.0 else (y1 - y0) / (x1 - x0)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   119
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   120
            if (y1 > y0) {
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   121
              last_edge += (a -> (x1, y1, s1))
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   122
              (b, s1.toString)
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   123
            }
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   124
            else (b, s0.toString)
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   125
          }).toList
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   126
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   127
        val data =
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   128
          SortedMap.empty[String, Double] ++
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   129
            (for {
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   130
              (x, y) <- props.iterator ++ speeds.iterator
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   131
              if x != Now.name && domain(x)
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   132
              z = java.lang.Double.parseDouble(y) if z != 0.0
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   133
            } yield { (x.intern, if (heap_fields._2.contains(x)) heap_scale(z) else z) })
65866
00e8b836d4db uniform heap_scale;
wenzelm
parents: 65864
diff changeset
   134
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   135
        result += ML_Statistics.Entry(time, data)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   136
      }
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   137
      result.toList
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   138
    }
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   139
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   140
    new ML_Statistics(heading, fields, content, time_start, duration)
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   141
  }
50685
293e8ec4dfc8 ML runtime statistics: read properties from build log;
wenzelm
parents:
diff changeset
   142
}
50688
f02864682307 some support for ML statistics content interpretation;
wenzelm
parents: 50685
diff changeset
   143
65855
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   144
final class ML_Statistics private(
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   145
  val heading: String,
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   146
  val fields: Set[String],
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   147
  val content: List[ML_Statistics.Entry],
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   148
  val time_start: Double,
33b3e76114f8 store processed content instead of somewhat bulky properties;
wenzelm
parents: 65854
diff changeset
   149
  val duration: Double)
50688
f02864682307 some support for ML statistics content interpretation;
wenzelm
parents: 50685
diff changeset
   150
{
65858
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   151
  /* content */
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   152
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   153
  def maximum(field: String): Double =
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   154
    (0.0 /: content)({ case (m, e) => m max e.get(field) })
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   155
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   156
  def average(field: String): Double =
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   157
  {
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   158
    @tailrec def sum(t0: Double, list: List[ML_Statistics.Entry], acc: Double): Double =
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   159
      list match {
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   160
        case Nil => acc
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   161
        case e :: es =>
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   162
          val t = e.time
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   163
          sum(t, es, (t - t0) * e.get(field) + acc)
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   164
      }
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   165
    content match {
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   166
      case Nil => 0.0
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   167
      case List(e) => e.get(field)
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   168
      case e :: es => sum(e.time, es, 0.0) / duration
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   169
    }
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   170
  }
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   171
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   172
  def maximum_heap_size: Long = maximum(ML_Statistics.HEAP_SIZE).toLong
9418a9fad835 more systematic maximum and average;
wenzelm
parents: 65855
diff changeset
   173
  def average_heap_size: Long = average(ML_Statistics.HEAP_SIZE).toLong
65854
db070951dfee include full ML statistics: max heap size;
wenzelm
parents: 65851
diff changeset
   174
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   175
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   176
  /* charts */
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   177
65864
1945fa8f0c39 simplified signature;
wenzelm
parents: 65858
diff changeset
   178
  def update_data(data: XYSeriesCollection, selected_fields: List[String])
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   179
  {
50697
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   180
    data.removeAllSeries
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   181
    for {
50690
03c4d75e8e32 some grouping of standard fields;
wenzelm
parents: 50689
diff changeset
   182
      field <- selected_fields.iterator
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   183
      series = new XYSeries(field)
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   184
    } {
67760
553d9ad7d679 more compact ML_Statistics, to make build_status work with less than 2GB heap;
wenzelm
parents: 65866
diff changeset
   185
      content.foreach(entry => series.add(entry.time, entry.get(field)))
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   186
      data.addSeries(series)
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   187
    }
50697
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   188
  }
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   189
65864
1945fa8f0c39 simplified signature;
wenzelm
parents: 65858
diff changeset
   190
  def chart(title: String, selected_fields: List[String]): JFreeChart =
50697
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   191
  {
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   192
    val data = new XYSeriesCollection
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   193
    update_data(data, selected_fields)
50689
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   194
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   195
    ChartFactory.createXYLineChart(title, "time", "value", data,
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   196
      PlotOrientation.VERTICAL, true, true, true)
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   197
  }
0607d557d073 some support for chart drawing;
wenzelm
parents: 50688
diff changeset
   198
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
   199
  def chart(fields: ML_Statistics.Fields): JFreeChart =
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
   200
    chart(fields._1, fields._2)
50691
20beafe66748 added standard_frames convenience;
wenzelm
parents: 50690
diff changeset
   201
65053
460f0fd2f77a clarified defaults;
wenzelm
parents: 65051
diff changeset
   202
  def show_frames(fields: List[ML_Statistics.Fields] = ML_Statistics.main_fields): Unit =
65051
f094e27e4902 tuned signature;
wenzelm
parents: 64045
diff changeset
   203
    fields.map(chart(_)).foreach(c =>
57612
990ffb84489b clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents: 53189
diff changeset
   204
      GUI_Thread.later {
50854
2b15227b17e8 add icon for toplevel windows;
wenzelm
parents: 50777
diff changeset
   205
        new Frame {
51615
072a7249e1ac separate module "GUI", to keep this out of the way of generic Isabelle_System operations, notably for non-Isabelle/jEdit applications;
wenzelm
parents: 51432
diff changeset
   206
          iconImage = GUI.isabelle_image()
65851
c103358a5559 tuned signature;
wenzelm
parents: 65477
diff changeset
   207
          title = heading
50854
2b15227b17e8 add icon for toplevel windows;
wenzelm
parents: 50777
diff changeset
   208
          contents = Component.wrap(new ChartPanel(c))
2b15227b17e8 add icon for toplevel windows;
wenzelm
parents: 50777
diff changeset
   209
          visible = true
2b15227b17e8 add icon for toplevel windows;
wenzelm
parents: 50777
diff changeset
   210
        }
50697
82e9178e6a98 improved Monitor_Dockable, based on ML_Statistics operations;
wenzelm
parents: 50691
diff changeset
   211
      })
50688
f02864682307 some support for ML statistics content interpretation;
wenzelm
parents: 50685
diff changeset
   212
}