src/Pure/Tools/task_statistics.scala
changeset 50982 a7aa17a1f721
parent 50980 bc746aa3e8d5
child 50989 a7f6ce0493b7
equal deleted inserted replaced
50981:1791a90a94fb 50982:a7aa17a1f721
    15 import org.jfree.chart.renderer.xy.{XYBarRenderer, StandardXYBarPainter}
    15 import org.jfree.chart.renderer.xy.{XYBarRenderer, StandardXYBarPainter}
    16 
    16 
    17 
    17 
    18 object Task_Statistics
    18 object Task_Statistics
    19 {
    19 {
    20   def apply(stats: List[Properties.T]): Task_Statistics = new Task_Statistics(stats)
    20   def apply(name: String, tasks: List[Properties.T]): Task_Statistics =
       
    21     new Task_Statistics(name, tasks)
       
    22 
       
    23   def apply(info: Build.Log_Info): Task_Statistics =
       
    24     apply(info.name, info.tasks)
    21 }
    25 }
    22 
    26 
    23 final class Task_Statistics private(val stats: List[Properties.T])
    27 final class Task_Statistics private(val name: String, val tasks: List[Properties.T])
    24 {
    28 {
    25   val Task_Name = new Properties.String("task_name")
    29   private val Task_Name = new Properties.String("task_name")
    26   val Run = new Properties.Int("run")
    30   private val Run = new Properties.Int("run")
    27 
    31 
    28   def chart(bins: Int = 100): JFreeChart =
    32   def chart(bins: Int = 100): JFreeChart =
    29   {
    33   {
    30     val values = new Array[Double](stats.length)
    34     val values = new Array[Double](tasks.length)
    31     for ((Run(x), i) <- stats.iterator.zipWithIndex) values(i) =
    35     for ((Run(x), i) <- tasks.iterator.zipWithIndex) values(i) =
    32       Math.log10(x.toDouble / 1000000)
    36       Math.log10(x.toDouble / 1000000)
    33 
    37 
    34     val data = new HistogramDataset
    38     val data = new HistogramDataset
    35     data.addSeries("tasks", values, bins)
    39     data.addSeries("tasks", values, bins)
    36 
    40 
    48 
    52 
    49   def show_frame(bins: Int = 100): Unit =
    53   def show_frame(bins: Int = 100): Unit =
    50     Swing_Thread.later {
    54     Swing_Thread.later {
    51       new Frame {
    55       new Frame {
    52         iconImage = Isabelle_System.get_icon().getImage
    56         iconImage = Isabelle_System.get_icon().getImage
    53         title = "Statistics"
    57         title = name
    54         contents = Component.wrap(new ChartPanel(chart(bins)))
    58         contents = Component.wrap(new ChartPanel(chart(bins)))
    55         visible = true
    59         visible = true
    56       }
    60       }
    57     }
    61     }
    58 }
    62 }