51240
|
1 |
/* Title: Pure/Tools/task_statistics.scala
|
50980
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Future task runtime statistics.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
|
10 |
import scala.swing.{Frame, Component}
|
|
11 |
|
|
12 |
import org.jfree.data.statistics.HistogramDataset
|
|
13 |
import org.jfree.chart.{JFreeChart, ChartPanel, ChartFactory}
|
|
14 |
import org.jfree.chart.plot.{XYPlot, PlotOrientation}
|
|
15 |
import org.jfree.chart.renderer.xy.{XYBarRenderer, StandardXYBarPainter}
|
|
16 |
|
|
17 |
|
|
18 |
object Task_Statistics
|
|
19 |
{
|
50982
|
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)
|
50980
|
25 |
}
|
|
26 |
|
50982
|
27 |
final class Task_Statistics private(val name: String, val tasks: List[Properties.T])
|
50980
|
28 |
{
|
50982
|
29 |
private val Task_Name = new Properties.String("task_name")
|
|
30 |
private val Run = new Properties.Int("run")
|
50980
|
31 |
|
|
32 |
def chart(bins: Int = 100): JFreeChart =
|
|
33 |
{
|
50982
|
34 |
val values = new Array[Double](tasks.length)
|
|
35 |
for ((Run(x), i) <- tasks.iterator.zipWithIndex) values(i) =
|
50989
|
36 |
java.lang.Math.log10(x.toDouble / 1000000)
|
50980
|
37 |
|
|
38 |
val data = new HistogramDataset
|
|
39 |
data.addSeries("tasks", values, bins)
|
|
40 |
|
|
41 |
val c =
|
|
42 |
ChartFactory.createHistogram("Task runtime distribution",
|
|
43 |
"log10(runtime / s)", "number of tasks", data,
|
|
44 |
PlotOrientation.VERTICAL, true, true, true)
|
|
45 |
|
|
46 |
val renderer = c.getPlot.asInstanceOf[XYPlot].getRenderer.asInstanceOf[XYBarRenderer]
|
|
47 |
renderer.setMargin(0.1)
|
|
48 |
renderer.setBarPainter(new StandardXYBarPainter)
|
|
49 |
|
|
50 |
c
|
|
51 |
}
|
|
52 |
|
|
53 |
def show_frame(bins: Int = 100): Unit =
|
|
54 |
Swing_Thread.later {
|
|
55 |
new Frame {
|
|
56 |
iconImage = Isabelle_System.get_icon().getImage
|
50982
|
57 |
title = name
|
50980
|
58 |
contents = Component.wrap(new ChartPanel(chart(bins)))
|
|
59 |
visible = true
|
|
60 |
}
|
|
61 |
}
|
|
62 |
}
|
|
63 |
|