| author | wenzelm | 
| Fri, 06 Mar 2020 20:33:16 +0100 | |
| changeset 71521 | e977609c30eb | 
| parent 65318 | 342efc382558 | 
| child 75393 | 87ebf5a50283 | 
| permissions | -rw-r--r-- | 
| 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 | {
 | |
| 64041 | 20 | def apply(session_name: String, task_statistics: List[Properties.T]): Task_Statistics = | 
| 21 | new Task_Statistics(session_name, task_statistics) | |
| 50980 | 22 | } | 
| 23 | ||
| 64041 | 24 | final class Task_Statistics private( | 
| 25 | val session_name: String, val task_statistics: List[Properties.T]) | |
| 50980 | 26 | {
 | 
| 50982 | 27 |   private val Task_Name = new Properties.String("task_name")
 | 
| 28 |   private val Run = new Properties.Int("run")
 | |
| 50980 | 29 | |
| 30 | def chart(bins: Int = 100): JFreeChart = | |
| 31 |   {
 | |
| 64041 | 32 | val values = new Array[Double](task_statistics.length) | 
| 33 | for ((Run(x), i) <- task_statistics.iterator.zipWithIndex) | |
| 51370 
716a94cc5aaf
avoid -Infinity which confuses JFreeChart histogram;
 wenzelm parents: 
51240diff
changeset | 34 | values(i) = java.lang.Math.log10((x max 1).toDouble / 1000000) | 
| 50980 | 35 | |
| 36 | val data = new HistogramDataset | |
| 37 |     data.addSeries("tasks", values, bins)
 | |
| 38 | ||
| 39 | val c = | |
| 40 |       ChartFactory.createHistogram("Task runtime distribution",
 | |
| 41 | "log10(runtime / s)", "number of tasks", data, | |
| 42 | PlotOrientation.VERTICAL, true, true, true) | |
| 43 | ||
| 44 | val renderer = c.getPlot.asInstanceOf[XYPlot].getRenderer.asInstanceOf[XYBarRenderer] | |
| 45 | renderer.setMargin(0.1) | |
| 46 | renderer.setBarPainter(new StandardXYBarPainter) | |
| 47 | ||
| 48 | c | |
| 49 | } | |
| 50 | ||
| 51 | def show_frame(bins: Int = 100): Unit = | |
| 57612 
990ffb84489b
clarified module name: facilitate alternative GUI frameworks;
 wenzelm parents: 
51615diff
changeset | 52 |     GUI_Thread.later {
 | 
| 50980 | 53 |       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: 
51370diff
changeset | 54 | iconImage = GUI.isabelle_image() | 
| 64041 | 55 | title = session_name | 
| 50980 | 56 | contents = Component.wrap(new ChartPanel(chart(bins))) | 
| 57 | visible = true | |
| 58 | } | |
| 59 | } | |
| 60 | } | |
| 61 |