src/Pure/Admin/build_status.scala
author wenzelm
Wed May 17 14:58:48 2017 +0200 (2017-05-17)
changeset 65854 db070951dfee
parent 65849 d70d2d68f7f0
child 65857 5d29d93766ef
permissions -rw-r--r--
include full ML statistics: max heap size;
wenzelm@65743
     1
/*  Title:      Pure/Admin/build_status.scala
wenzelm@63686
     2
    Author:     Makarius
wenzelm@63686
     3
wenzelm@65743
     4
Present recent build status information from database.
wenzelm@63686
     5
*/
wenzelm@63686
     6
wenzelm@63686
     7
package isabelle
wenzelm@63686
     8
wenzelm@63686
     9
wenzelm@65743
    10
object Build_Status
wenzelm@63686
    11
{
wenzelm@65799
    12
  /* defaults */
wenzelm@65799
    13
wenzelm@65799
    14
  val default_target_dir = Path.explode("build_status")
wenzelm@65799
    15
  val default_image_size = (800, 600)
wenzelm@65799
    16
  val default_history = 30
wenzelm@65799
    17
wenzelm@65799
    18
  def default_profiles: List[Profile] =
wenzelm@65799
    19
    Jenkins.build_status_profiles ::: Isabelle_Cronjob.build_status_profiles
wenzelm@65799
    20
wenzelm@65799
    21
wenzelm@65791
    22
  /* data profiles */
wenzelm@65791
    23
wenzelm@65798
    24
  sealed case class Profile(description: String, history: Int, sql: String)
wenzelm@65791
    25
  {
wenzelm@65799
    26
    def days(options: Options): Int = options.int("build_log_history") max history
wenzelm@65799
    27
wenzelm@65799
    28
    def stretch(options: Options): Double =
wenzelm@65799
    29
      (days(options) max default_history min (default_history * 5)).toDouble / default_history
wenzelm@65799
    30
wenzelm@65799
    31
    def select(options: Options, columns: List[SQL.Column], only_sessions: Set[String]): SQL.Source =
wenzelm@65791
    32
    {
wenzelm@65791
    33
      Build_Log.Data.universal_table.select(columns, distinct = true,
wenzelm@65791
    34
        sql = "WHERE " +
wenzelm@65799
    35
          Build_Log.Data.pull_date + " > " + Build_Log.Data.recent_time(days(options)) + " AND " +
wenzelm@65791
    36
          Build_Log.Data.status + " = " + SQL.string(Build_Log.Session_Status.finished.toString) +
wenzelm@65804
    37
          (if (only_sessions.isEmpty) ""
wenzelm@65804
    38
           else " AND " + SQL.member(Build_Log.Data.session_name.ident, only_sessions)) +
wenzelm@65804
    39
          " AND " + SQL.enclose(sql) +
wenzelm@65849
    40
          " ORDER BY " + Build_Log.Data.pull_date)
wenzelm@65791
    41
    }
wenzelm@65791
    42
  }
wenzelm@65791
    43
wenzelm@65791
    44
wenzelm@65785
    45
  /* build status */
wenzelm@65785
    46
wenzelm@65785
    47
  def build_status(options: Options,
wenzelm@65785
    48
    progress: Progress = No_Progress,
wenzelm@65785
    49
    profiles: List[Profile] = default_profiles,
wenzelm@65785
    50
    only_sessions: Set[String] = Set.empty,
wenzelm@65785
    51
    verbose: Boolean = false,
wenzelm@65785
    52
    target_dir: Path = default_target_dir,
wenzelm@65854
    53
    ml_statistics: Boolean = false,
wenzelm@65785
    54
    image_size: (Int, Int) = default_image_size)
wenzelm@65785
    55
  {
wenzelm@65785
    56
    val data =
wenzelm@65785
    57
      read_data(options, progress = progress, profiles = profiles,
wenzelm@65854
    58
        only_sessions = only_sessions, ml_statistics = ml_statistics, verbose = verbose)
wenzelm@65785
    59
wenzelm@65785
    60
    present_data(data, progress = progress, target_dir = target_dir, image_size = image_size)
wenzelm@65785
    61
  }
wenzelm@65736
    62
wenzelm@65736
    63
wenzelm@65791
    64
  /* read data */
wenzelm@65736
    65
wenzelm@65792
    66
  sealed case class Data(date: Date, entries: List[Data_Entry])
wenzelm@65799
    67
  sealed case class Data_Entry(
wenzelm@65799
    68
    name: String, hosts: List[String], stretch: Double, sessions: List[Session])
wenzelm@65765
    69
  sealed case class Session(name: String, threads: Int, entries: List[Entry])
wenzelm@65754
    70
  {
wenzelm@65795
    71
    require(entries.nonEmpty)
wenzelm@65795
    72
wenzelm@65796
    73
    def pull_date: Date = entries.head.pull_date
wenzelm@65796
    74
    def isabelle_version: String = entries.head.isabelle_version
wenzelm@65796
    75
    def afp_version: String = entries.head.afp_version
wenzelm@65796
    76
wenzelm@65795
    77
    def timing: Timing = entries.head.timing
wenzelm@65795
    78
    def ml_timing: Timing = entries.head.ml_timing
wenzelm@65762
    79
    def order: Long = - timing.elapsed.ms
wenzelm@65769
    80
wenzelm@65769
    81
    def check_timing: Boolean = entries.length >= 3
wenzelm@65854
    82
    def check_heap: Boolean =
wenzelm@65854
    83
      entries.length >= 3 &&
wenzelm@65854
    84
      entries.forall(entry => entry.heap_size > 0 || entry.heap_size_max > 0)
wenzelm@65754
    85
  }
wenzelm@65854
    86
  sealed case class Entry(
wenzelm@65854
    87
    pull_date: Date,
wenzelm@65854
    88
    isabelle_version: String,
wenzelm@65854
    89
    afp_version: String,
wenzelm@65854
    90
    timing: Timing,
wenzelm@65854
    91
    ml_timing: Timing,
wenzelm@65854
    92
    heap_size: Long,
wenzelm@65854
    93
    heap_size_max: Long,
wenzelm@65854
    94
    ml_statistics: ML_Statistics)
wenzelm@65736
    95
wenzelm@65736
    96
  def read_data(options: Options,
wenzelm@65736
    97
    progress: Progress = No_Progress,
wenzelm@65785
    98
    profiles: List[Profile] = default_profiles,
wenzelm@65736
    99
    only_sessions: Set[String] = Set.empty,
wenzelm@65854
   100
    ml_statistics: Boolean = false,
wenzelm@65750
   101
    verbose: Boolean = false): Data =
wenzelm@65736
   102
  {
wenzelm@65754
   103
    val date = Date.now()
wenzelm@65792
   104
    var data_hosts = Map.empty[String, Set[String]]
wenzelm@65799
   105
    var data_stretch = Map.empty[String, Double]
wenzelm@65762
   106
    var data_entries = Map.empty[String, Map[String, Session]]
wenzelm@63688
   107
wenzelm@65792
   108
    def get_hosts(data_name: String): Set[String] =
wenzelm@65792
   109
      data_hosts.getOrElse(data_name, Set.empty)
wenzelm@65792
   110
wenzelm@65736
   111
    val store = Build_Log.store(options)
wenzelm@65736
   112
    using(store.open_database())(db =>
wenzelm@64089
   113
    {
wenzelm@65764
   114
      for (profile <- profiles.sortBy(_.description)) {
wenzelm@65764
   115
        progress.echo("input " + quote(profile.description))
wenzelm@65854
   116
wenzelm@65736
   117
        val columns =
wenzelm@65736
   118
          List(
wenzelm@65736
   119
            Build_Log.Data.pull_date,
wenzelm@65792
   120
            Build_Log.Prop.build_host,
wenzelm@65796
   121
            Build_Log.Prop.isabelle_version,
wenzelm@65796
   122
            Build_Log.Prop.afp_version,
wenzelm@65752
   123
            Build_Log.Settings.ISABELLE_BUILD_OPTIONS,
wenzelm@65736
   124
            Build_Log.Settings.ML_PLATFORM,
wenzelm@65736
   125
            Build_Log.Data.session_name,
wenzelm@65736
   126
            Build_Log.Data.threads,
wenzelm@65736
   127
            Build_Log.Data.timing_elapsed,
wenzelm@65736
   128
            Build_Log.Data.timing_cpu,
wenzelm@65736
   129
            Build_Log.Data.timing_gc,
wenzelm@65736
   130
            Build_Log.Data.ml_timing_elapsed,
wenzelm@65736
   131
            Build_Log.Data.ml_timing_cpu,
wenzelm@65769
   132
            Build_Log.Data.ml_timing_gc,
wenzelm@65854
   133
            Build_Log.Data.heap_size) :::
wenzelm@65854
   134
          (if (ml_statistics) List(Build_Log.Data.ml_statistics) else Nil)
wenzelm@63700
   135
wenzelm@65752
   136
        val Threads_Option = """threads\s*=\s*(\d+)""".r
wenzelm@65752
   137
wenzelm@65799
   138
        val sql = profile.select(options, columns, only_sessions)
wenzelm@65750
   139
        if (verbose) progress.echo(sql)
wenzelm@65750
   140
wenzelm@65750
   141
        db.using_statement(sql)(stmt =>
wenzelm@65736
   142
        {
wenzelm@65740
   143
          val res = stmt.execute_query()
wenzelm@65740
   144
          while (res.next()) {
wenzelm@65766
   145
            val session_name = res.string(Build_Log.Data.session_name)
wenzelm@65764
   146
            val threads =
wenzelm@65764
   147
            {
wenzelm@65764
   148
              val threads1 =
wenzelm@65764
   149
                res.string(Build_Log.Settings.ISABELLE_BUILD_OPTIONS) match {
wenzelm@65766
   150
                  case Threads_Option(Value.Int(i)) if session_name == "Pure" => i
wenzelm@65764
   151
                  case _ => 1
wenzelm@65764
   152
                }
wenzelm@65764
   153
              val threads2 = res.get_int(Build_Log.Data.threads).getOrElse(1)
wenzelm@65764
   154
              threads1 max threads2
wenzelm@65764
   155
            }
wenzelm@65766
   156
            val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM)
wenzelm@65762
   157
            val data_name =
wenzelm@65764
   158
              profile.description +
wenzelm@65764
   159
                (if (ml_platform.startsWith("x86_64")) ", 64bit" else "") +
wenzelm@65764
   160
                (if (threads == 1) "" else ", " + threads + " threads")
wenzelm@63703
   161
wenzelm@65799
   162
            res.get_string(Build_Log.Prop.build_host).foreach(host =>
wenzelm@65799
   163
              data_hosts += (data_name -> (get_hosts(data_name) + host)))
wenzelm@65799
   164
wenzelm@65799
   165
            data_stretch += (data_name -> profile.stretch(options))
wenzelm@65799
   166
wenzelm@65854
   167
            val isabelle_version = res.string(Build_Log.Prop.isabelle_version)
wenzelm@65854
   168
wenzelm@65854
   169
            val ml_stats =
wenzelm@65854
   170
              ML_Statistics(
wenzelm@65854
   171
                if (ml_statistics)
wenzelm@65854
   172
                    store.uncompress_properties(res.bytes(Build_Log.Data.ml_statistics))
wenzelm@65854
   173
                else Nil, heading = session_name + " (Isabelle/ " + isabelle_version + ")")
wenzelm@65854
   174
wenzelm@65736
   175
            val entry =
wenzelm@65796
   176
              Entry(
wenzelm@65796
   177
                pull_date = res.date(Build_Log.Data.pull_date),
wenzelm@65854
   178
                isabelle_version = isabelle_version,
wenzelm@65796
   179
                afp_version = res.string(Build_Log.Prop.afp_version),
wenzelm@65796
   180
                timing =
wenzelm@65796
   181
                  res.timing(
wenzelm@65796
   182
                    Build_Log.Data.timing_elapsed,
wenzelm@65796
   183
                    Build_Log.Data.timing_cpu,
wenzelm@65796
   184
                    Build_Log.Data.timing_gc),
wenzelm@65796
   185
                ml_timing =
wenzelm@65796
   186
                  res.timing(
wenzelm@65796
   187
                    Build_Log.Data.ml_timing_elapsed,
wenzelm@65796
   188
                    Build_Log.Data.ml_timing_cpu,
wenzelm@65796
   189
                    Build_Log.Data.ml_timing_gc),
wenzelm@65854
   190
                heap_size = res.long(Build_Log.Data.heap_size),
wenzelm@65854
   191
                heap_size_max = ml_stats.heap_size_max,
wenzelm@65854
   192
                ml_statistics = ml_stats)
wenzelm@65736
   193
wenzelm@65762
   194
            val sessions = data_entries.getOrElse(data_name, Map.empty)
wenzelm@65766
   195
            val entries = sessions.get(session_name).map(_.entries) getOrElse Nil
wenzelm@65766
   196
            val session = Session(session_name, threads, entry :: entries)
wenzelm@65766
   197
            data_entries += (data_name -> (sessions + (session_name -> session)))
wenzelm@65736
   198
          }
wenzelm@65736
   199
        })
wenzelm@65736
   200
      }
wenzelm@65736
   201
    })
wenzelm@65736
   202
wenzelm@65792
   203
    val sorted_entries =
wenzelm@65762
   204
      (for {
wenzelm@65792
   205
        (name, sessions) <- data_entries.toList
wenzelm@65847
   206
        sorted_sessions <- proper_list(sessions.toList.map(_._2).sortBy(_.order))
wenzelm@65799
   207
      }
wenzelm@65799
   208
      yield {
wenzelm@65799
   209
        val hosts = get_hosts(name).toList.sorted
wenzelm@65799
   210
        val stretch = data_stretch(name)
wenzelm@65799
   211
        Data_Entry(name, hosts, stretch, sorted_sessions)
wenzelm@65799
   212
      }).sortBy(_.name)
wenzelm@65792
   213
wenzelm@65792
   214
    Data(date, sorted_entries)
wenzelm@65736
   215
  }
wenzelm@65736
   216
wenzelm@65736
   217
wenzelm@65736
   218
  /* present data */
wenzelm@65736
   219
wenzelm@65736
   220
  def present_data(data: Data,
wenzelm@65736
   221
    progress: Progress = No_Progress,
wenzelm@65736
   222
    target_dir: Path = default_target_dir,
wenzelm@65759
   223
    image_size: (Int, Int) = default_image_size)
wenzelm@65736
   224
  {
wenzelm@65791
   225
    def clean_name(name: String): String =
wenzelm@65791
   226
      name.flatMap(c => if (c == ' ' || c == '/') "_" else if (c == ',') "" else c.toString)
wenzelm@65791
   227
wenzelm@65854
   228
    def heap_scale(x: Long): Double = x.toDouble / (1024 * 1024)
wenzelm@65854
   229
wenzelm@65838
   230
    HTML.write_document(target_dir, "index.html",
wenzelm@65838
   231
      List(HTML.title("Isabelle build status")),
wenzelm@65838
   232
      List(HTML.chapter("Isabelle build status"),
wenzelm@65838
   233
        HTML.par(
wenzelm@65838
   234
          List(HTML.description(
wenzelm@65838
   235
            List(HTML.text("status date:") -> HTML.text(data.date.toString))))),
wenzelm@65838
   236
        HTML.par(
wenzelm@65838
   237
          List(HTML.itemize(data.entries.map({ case data_entry =>
wenzelm@65838
   238
            List(HTML.link(clean_name(data_entry.name) + "/index.html",
wenzelm@65838
   239
              HTML.text(data_entry.name))) }))))))
wenzelm@65786
   240
wenzelm@65792
   241
    for (data_entry <- data.entries) {
wenzelm@65792
   242
      val data_name = data_entry.name
wenzelm@65792
   243
wenzelm@65799
   244
      val image_width = (image_size._1 * data_entry.stretch).toInt
wenzelm@65799
   245
      val image_height = image_size._2
wenzelm@65799
   246
wenzelm@65786
   247
      progress.echo("output " + quote(data_name))
wenzelm@65786
   248
wenzelm@65764
   249
      val dir = target_dir + Path.basic(clean_name(data_name))
wenzelm@65736
   250
      Isabelle_System.mkdirs(dir)
wenzelm@65736
   251
wenzelm@65764
   252
      val session_plots =
wenzelm@65764
   253
        Par_List.map((session: Session) =>
wenzelm@65764
   254
          Isabelle_System.with_tmp_file(session.name, "data") { data_file =>
wenzelm@65764
   255
            Isabelle_System.with_tmp_file(session.name, "gnuplot") { gnuplot_file =>
wenzelm@63706
   256
wenzelm@65764
   257
              File.write(data_file,
wenzelm@65764
   258
                cat_lines(
wenzelm@65764
   259
                  session.entries.map(entry =>
wenzelm@65854
   260
                    List(entry.pull_date.unix_epoch,
wenzelm@65764
   261
                      entry.timing.elapsed.minutes,
wenzelm@65764
   262
                      entry.timing.resources.minutes,
wenzelm@65764
   263
                      entry.ml_timing.elapsed.minutes,
wenzelm@65769
   264
                      entry.ml_timing.resources.minutes,
wenzelm@65854
   265
                      heap_scale(entry.heap_size),
wenzelm@65854
   266
                      heap_scale(entry.heap_size_max)).mkString(" "))))
wenzelm@65736
   267
wenzelm@65764
   268
              val max_time =
wenzelm@65764
   269
                ((0.0 /: session.entries){ case (m, entry) =>
wenzelm@65764
   270
                  m.max(entry.timing.elapsed.minutes).
wenzelm@65764
   271
                    max(entry.timing.resources.minutes).
wenzelm@65764
   272
                    max(entry.ml_timing.elapsed.minutes).
wenzelm@65764
   273
                    max(entry.ml_timing.resources.minutes) } max 0.1) * 1.1
wenzelm@65769
   274
              val timing_range = "[0:" + max_time + "]"
wenzelm@65763
   275
wenzelm@65769
   276
              def gnuplot(plots: List[String], kind: String, range: String): String =
wenzelm@65764
   277
              {
wenzelm@65764
   278
                val plot_name = session.name + "_" + kind + ".png"
wenzelm@65764
   279
wenzelm@65764
   280
                File.write(gnuplot_file, """
wenzelm@65799
   281
set terminal png size """ + image_width + "," + image_height + """
wenzelm@65764
   282
set output """ + quote(File.standard_path(dir + Path.basic(plot_name))) + """
wenzelm@65759
   283
set xdata time
wenzelm@65759
   284
set timefmt "%s"
wenzelm@65759
   285
set format x "%d-%b"
wenzelm@65762
   286
set xlabel """ + quote(session.name) + """ noenhanced
wenzelm@65763
   287
set key left bottom
wenzelm@65769
   288
plot [] """ + range + " " +
wenzelm@65769
   289
                plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n")
wenzelm@65759
   290
wenzelm@65764
   291
                val result =
wenzelm@65764
   292
                  Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file))
wenzelm@65764
   293
                if (!result.ok)
wenzelm@65764
   294
                  result.error("Gnuplot failed for " + data_name + "/" + plot_name).check
wenzelm@65764
   295
wenzelm@65764
   296
                plot_name
wenzelm@65764
   297
              }
wenzelm@65759
   298
wenzelm@65765
   299
              val timing_plots =
wenzelm@65769
   300
              {
wenzelm@65769
   301
                val plots1 =
wenzelm@65769
   302
                  List(
wenzelm@65769
   303
                    """ using 1:2 smooth sbezier title "elapsed time (smooth)" """,
wenzelm@65769
   304
                    """ using 1:2 smooth csplines title "elapsed time" """)
wenzelm@65769
   305
                val plots2 =
wenzelm@65769
   306
                  List(
wenzelm@65769
   307
                    """ using 1:3 smooth sbezier title "cpu time (smooth)" """,
wenzelm@65769
   308
                    """ using 1:3 smooth csplines title "cpu time" """)
wenzelm@65769
   309
                if (session.threads == 1) plots1 else plots1 ::: plots2
wenzelm@65769
   310
              }
wenzelm@65765
   311
wenzelm@65764
   312
              val ml_timing_plots =
wenzelm@65764
   313
                List(
wenzelm@65765
   314
                  """ using 1:4 smooth sbezier title "ML elapsed time (smooth)" """,
wenzelm@65765
   315
                  """ using 1:4 smooth csplines title "ML elapsed time" """,
wenzelm@65764
   316
                  """ using 1:5 smooth sbezier title "ML cpu time (smooth)" """,
wenzelm@65765
   317
                  """ using 1:5 smooth csplines title "ML cpu time" """)
wenzelm@65736
   318
wenzelm@65769
   319
              val heap_plots =
wenzelm@65769
   320
                List(
wenzelm@65854
   321
                  """ using 1:6 smooth sbezier title "final heap (smooth)" """,
wenzelm@65854
   322
                  """ using 1:6 smooth csplines title "final heap" """,
wenzelm@65854
   323
                  """ using 1:7 smooth sbezier title "max heap (smooth)" """,
wenzelm@65854
   324
                  """ using 1:7 smooth csplines title "max heap" """)
wenzelm@65769
   325
wenzelm@65769
   326
              val plot_names =
wenzelm@65847
   327
                (if (session.check_timing)
wenzelm@65847
   328
                  List(
wenzelm@65847
   329
                    gnuplot(timing_plots, "timing", timing_range),
wenzelm@65847
   330
                    gnuplot(ml_timing_plots, "ml_timing", timing_range))
wenzelm@65847
   331
                 else Nil) :::
wenzelm@65769
   332
                (if (session.check_heap) List(gnuplot(heap_plots, "heap", "[0:]")) else Nil)
wenzelm@65769
   333
wenzelm@65769
   334
              session.name -> plot_names
wenzelm@65764
   335
            }
wenzelm@65792
   336
          }, data_entry.sessions).toMap
wenzelm@65754
   337
wenzelm@65838
   338
      HTML.write_document(dir, "index.html",
wenzelm@65838
   339
        List(HTML.title("Isabelle build status for " + data_name)),
wenzelm@65838
   340
        HTML.chapter("Isabelle build status for " + data_name) ::
wenzelm@65838
   341
        HTML.par(
wenzelm@65838
   342
          List(HTML.description(
wenzelm@65754
   343
            List(
wenzelm@65838
   344
              HTML.text("status date:") -> HTML.text(data.date.toString),
wenzelm@65838
   345
              HTML.text("build host:") -> HTML.text(commas(data_entry.hosts)))))) ::
wenzelm@65838
   346
        HTML.par(
wenzelm@65838
   347
          List(HTML.itemize(
wenzelm@65838
   348
            data_entry.sessions.map(session =>
wenzelm@65838
   349
              HTML.link("#session_" + session.name, HTML.text(session.name)) ::
wenzelm@65838
   350
              HTML.text(" (" + session.timing.message_resources + ")"))))) ::
wenzelm@65838
   351
        data_entry.sessions.flatMap(session =>
wenzelm@65838
   352
          List(
wenzelm@65838
   353
            HTML.section(session.name) + HTML.id("session_" + session.name),
wenzelm@65838
   354
            HTML.par(
wenzelm@65838
   355
              HTML.description(
wenzelm@65838
   356
                List(
wenzelm@65838
   357
                  HTML.text("timing:") -> HTML.text(session.timing.message_resources),
wenzelm@65838
   358
                  HTML.text("ML timing:") -> HTML.text(session.ml_timing.message_resources)) :::
wenzelm@65838
   359
                proper_string(session.isabelle_version).map(s =>
wenzelm@65838
   360
                  HTML.text("Isabelle version:") -> HTML.text(s)).toList :::
wenzelm@65838
   361
                proper_string(session.afp_version).map(s =>
wenzelm@65838
   362
                  HTML.text("AFP version:") -> HTML.text(s)).toList) ::
wenzelm@65838
   363
              session_plots.getOrElse(session.name, Nil).map(plot_name =>
wenzelm@65838
   364
                HTML.image(plot_name) +
wenzelm@65838
   365
                  HTML.width(image_width / 2) +
wenzelm@65838
   366
                  HTML.height(image_height / 2))))))
wenzelm@63688
   367
    }
wenzelm@63688
   368
  }
wenzelm@63688
   369
wenzelm@63688
   370
wenzelm@63688
   371
  /* Isabelle tool wrapper */
wenzelm@63688
   372
wenzelm@63688
   373
  val isabelle_tool =
wenzelm@65743
   374
    Isabelle_Tool("build_status", "present recent build status information from database", args =>
wenzelm@63688
   375
    {
wenzelm@65736
   376
      var target_dir = default_target_dir
wenzelm@65854
   377
      var ml_statistics = false
wenzelm@65736
   378
      var only_sessions = Set.empty[String]
wenzelm@65736
   379
      var options = Options.init()
wenzelm@65736
   380
      var image_size = default_image_size
wenzelm@65750
   381
      var verbose = false
wenzelm@63688
   382
wenzelm@63688
   383
      val getopts = Getopts("""
wenzelm@65743
   384
Usage: isabelle build_status [OPTIONS]
wenzelm@63688
   385
wenzelm@63688
   386
  Options are:
wenzelm@65737
   387
    -D DIR       target directory (default """ + default_target_dir + """)
wenzelm@65854
   388
    -M           include full ML statistics
wenzelm@63700
   389
    -S SESSIONS  only given SESSIONS (comma separated)
wenzelm@65736
   390
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
wenzelm@65737
   391
    -s WxH       size of PNG image (default """ + image_size._1 + "x" + image_size._2 + """)
wenzelm@65750
   392
    -v           verbose
wenzelm@63688
   393
wenzelm@65736
   394
  Present performance statistics from build log database, which is specified
wenzelm@65782
   395
  via system options build_log_database_host, build_log_database_user,
wenzelm@65782
   396
  build_log_history etc.
wenzelm@63688
   397
""",
wenzelm@63688
   398
        "D:" -> (arg => target_dir = Path.explode(arg)),
wenzelm@65854
   399
        "M" -> (_ => ml_statistics = true),
wenzelm@63700
   400
        "S:" -> (arg => only_sessions = space_explode(',', arg).toSet),
wenzelm@65736
   401
        "o:" -> (arg => options = options + arg),
wenzelm@63700
   402
        "s:" -> (arg =>
wenzelm@63805
   403
          space_explode('x', arg).map(Value.Int.parse(_)) match {
wenzelm@65736
   404
            case List(w, h) if w > 0 && h > 0 => image_size = (w, h)
wenzelm@63700
   405
            case _ => error("Error bad PNG image size: " + quote(arg))
wenzelm@65750
   406
          }),
wenzelm@65750
   407
        "v" -> (_ => verbose = true))
wenzelm@63688
   408
wenzelm@65736
   409
      val more_args = getopts(args)
wenzelm@65736
   410
      if (more_args.nonEmpty) getopts.usage()
wenzelm@63700
   411
wenzelm@65736
   412
      val progress = new Console_Progress
wenzelm@63688
   413
wenzelm@65785
   414
      build_status(options, progress = progress, only_sessions = only_sessions, verbose = verbose,
wenzelm@65854
   415
        target_dir = target_dir, ml_statistics = ml_statistics, image_size = image_size)
wenzelm@65736
   416
wenzelm@64161
   417
  }, admin = true)
wenzelm@63686
   418
}