50980
|
1 |
/* Title: Pure/ML/task_statistics.ML
|
|
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 |
{
|
|
20 |
def apply(stats: List[Properties.T]): Task_Statistics = new Task_Statistics(stats)
|
|
21 |
}
|
|
22 |
|
|
23 |
final class Task_Statistics private(val stats: List[Properties.T])
|
|
24 |
{
|
|
25 |
val Task_Name = new Properties.String("task_name")
|
|
26 |
val Run = new Properties.Int("run")
|
|
27 |
|
|
28 |
def chart(bins: Int = 100): JFreeChart =
|
|
29 |
{
|
|
30 |
val values = new Array[Double](stats.length)
|
|
31 |
for ((Run(x), i) <- stats.iterator.zipWithIndex) values(i) =
|
|
32 |
Math.log10(x.toDouble / 1000000)
|
|
33 |
|
|
34 |
val data = new HistogramDataset
|
|
35 |
data.addSeries("tasks", values, bins)
|
|
36 |
|
|
37 |
val c =
|
|
38 |
ChartFactory.createHistogram("Task runtime distribution",
|
|
39 |
"log10(runtime / s)", "number of tasks", data,
|
|
40 |
PlotOrientation.VERTICAL, true, true, true)
|
|
41 |
|
|
42 |
val renderer = c.getPlot.asInstanceOf[XYPlot].getRenderer.asInstanceOf[XYBarRenderer]
|
|
43 |
renderer.setMargin(0.1)
|
|
44 |
renderer.setBarPainter(new StandardXYBarPainter)
|
|
45 |
|
|
46 |
c
|
|
47 |
}
|
|
48 |
|
|
49 |
def show_frame(bins: Int = 100): Unit =
|
|
50 |
Swing_Thread.later {
|
|
51 |
new Frame {
|
|
52 |
iconImage = Isabelle_System.get_icon().getImage
|
|
53 |
title = "Statistics"
|
|
54 |
contents = Component.wrap(new ChartPanel(chart(bins)))
|
|
55 |
visible = true
|
|
56 |
}
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|