clarified name;
authorwenzelm
Sat May 06 19:23:33 2017 +0200 (2017-05-06)
changeset 657434847ca570454
parent 65742 b9e0f25ba16a
child 65744 92028ab1c3d7
clarified name;
src/Pure/Admin/build_stats.scala
src/Pure/Admin/build_status.scala
src/Pure/Admin/jenkins.scala
src/Pure/System/isabelle_tool.scala
src/Pure/build-jars
     1.1 --- a/src/Pure/Admin/build_stats.scala	Sat May 06 12:59:16 2017 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,278 +0,0 @@
     1.4 -/*  Title:      Pure/Admin/build_stats.scala
     1.5 -    Author:     Makarius
     1.6 -
     1.7 -Performance statistics from build log database.
     1.8 -*/
     1.9 -
    1.10 -package isabelle
    1.11 -
    1.12 -
    1.13 -object Build_Stats
    1.14 -{
    1.15 -  private val default_target_dir = Path.explode("stats")
    1.16 -  private val default_history_length = 30
    1.17 -  private val default_image_size = (800, 600)
    1.18 -
    1.19 -
    1.20 -  /* data profiles */
    1.21 -
    1.22 -  sealed case class Profile(name: String, sql: String)
    1.23 -  {
    1.24 -    def select(columns: List[SQL.Column], days: Int, only_sessions: Set[String]): SQL.Source =
    1.25 -    {
    1.26 -      val sql_sessions =
    1.27 -        if (only_sessions.isEmpty) ""
    1.28 -        else
    1.29 -          only_sessions.iterator.map(a => Build_Log.Data.session_name + " = " + SQL.string(a))
    1.30 -            .mkString("(", " OR ", ") AND ")
    1.31 -
    1.32 -      Build_Log.Data.universal_table.select(columns, distinct = true,
    1.33 -        sql = "WHERE " +
    1.34 -          Build_Log.Data.pull_date + " > " + Build_Log.Data.recent_time(days) + " AND " +
    1.35 -          Build_Log.Data.status + " = " + SQL.string(Build_Log.Session_Status.finished.toString) +
    1.36 -          " AND " + sql_sessions + SQL.enclose(sql) +
    1.37 -          " ORDER BY " + Build_Log.Data.pull_date + " DESC")
    1.38 -    }
    1.39 -  }
    1.40 -
    1.41 -  val standard_profiles: List[Profile] =
    1.42 -    Jenkins.build_log_profiles :::
    1.43 -    Isabelle_Cronjob.remote_builds.flatten.toList.map(r => Profile(r.name, r.sql))
    1.44 -
    1.45 -  sealed case class Entry(date: Date, timing: Timing, ml_timing: Timing)
    1.46 -  {
    1.47 -    def check(elapsed_threshold: Time): Boolean =
    1.48 -      !timing.is_zero && timing.elapsed >= elapsed_threshold
    1.49 -  }
    1.50 -
    1.51 -  type Data = Map[String, Map[String, List[Entry]]]
    1.52 -
    1.53 -
    1.54 -  /* read data */
    1.55 -
    1.56 -  def read_data(options: Options,
    1.57 -    profiles: List[Profile] = standard_profiles,
    1.58 -    progress: Progress = No_Progress,
    1.59 -    history_length: Int = default_history_length,
    1.60 -    only_sessions: Set[String] = Set.empty,
    1.61 -    elapsed_threshold: Time = Time.zero): Data =
    1.62 -  {
    1.63 -    var data: Data = Map.empty
    1.64 -
    1.65 -    val store = Build_Log.store(options)
    1.66 -    using(store.open_database())(db =>
    1.67 -    {
    1.68 -      for (profile <- profiles) {
    1.69 -        progress.echo("input " + quote(profile.name))
    1.70 -        val columns =
    1.71 -          List(
    1.72 -            Build_Log.Data.pull_date,
    1.73 -            Build_Log.Settings.ML_PLATFORM,
    1.74 -            Build_Log.Data.session_name,
    1.75 -            Build_Log.Data.threads,
    1.76 -            Build_Log.Data.timing_elapsed,
    1.77 -            Build_Log.Data.timing_cpu,
    1.78 -            Build_Log.Data.timing_gc,
    1.79 -            Build_Log.Data.ml_timing_elapsed,
    1.80 -            Build_Log.Data.ml_timing_cpu,
    1.81 -            Build_Log.Data.ml_timing_gc)
    1.82 -
    1.83 -        db.using_statement(profile.select(columns, history_length, only_sessions))(stmt =>
    1.84 -        {
    1.85 -          val res = stmt.execute_query()
    1.86 -          while (res.next()) {
    1.87 -            val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM)
    1.88 -            val threads = res.get_int(Build_Log.Data.threads)
    1.89 -            val name =
    1.90 -              profile.name +
    1.91 -                "_m" + (if (ml_platform.startsWith("x86_64")) "64" else "32") +
    1.92 -                "_M" + threads.getOrElse(1)
    1.93 -
    1.94 -            val session = res.string(Build_Log.Data.session_name)
    1.95 -            val entry =
    1.96 -              Entry(res.date(Build_Log.Data.pull_date),
    1.97 -                res.timing(
    1.98 -                  Build_Log.Data.timing_elapsed,
    1.99 -                  Build_Log.Data.timing_cpu,
   1.100 -                  Build_Log.Data.timing_gc),
   1.101 -                res.timing(
   1.102 -                  Build_Log.Data.ml_timing_elapsed,
   1.103 -                  Build_Log.Data.ml_timing_cpu,
   1.104 -                  Build_Log.Data.ml_timing_gc))
   1.105 -
   1.106 -            val session_entries = data.getOrElse(name, Map.empty)
   1.107 -            val entries = session_entries.getOrElse(session, Nil)
   1.108 -            data += (name -> (session_entries + (session -> (entry :: entries))))
   1.109 -          }
   1.110 -        })
   1.111 -      }
   1.112 -    })
   1.113 -
   1.114 -    for {
   1.115 -      (name, session_entries) <- data
   1.116 -      session_entries1 <-
   1.117 -        {
   1.118 -          val session_entries1 =
   1.119 -            for {
   1.120 -              (session, entries) <- session_entries
   1.121 -              if entries.filter(_.check(elapsed_threshold)).length >= 3
   1.122 -            } yield (session, entries)
   1.123 -          if (session_entries1.isEmpty) None
   1.124 -          else Some(session_entries1)
   1.125 -        }
   1.126 -    } yield (name, session_entries1)
   1.127 -  }
   1.128 -
   1.129 -
   1.130 -  /* present data */
   1.131 -
   1.132 -  private val html_header = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
   1.133 -<html>
   1.134 -<head><title>Performance statistics from build log database</title></head>
   1.135 -<body>
   1.136 -"""
   1.137 -  private val html_footer = """
   1.138 -</body>
   1.139 -</html>
   1.140 -"""
   1.141 -
   1.142 -  def present_data(data: Data,
   1.143 -    progress: Progress = No_Progress,
   1.144 -    target_dir: Path = default_target_dir,
   1.145 -    image_size: (Int, Int) = default_image_size,
   1.146 -    ml_timing: Option[Boolean] = None)
   1.147 -  {
   1.148 -    val data_entries = data.toList.sortBy(_._1)
   1.149 -    for ((name, session_entries) <- data_entries) {
   1.150 -      val dir = target_dir + Path.explode(name)
   1.151 -      progress.echo("output " + dir)
   1.152 -      Isabelle_System.mkdirs(dir)
   1.153 -
   1.154 -      for ((session, entries) <- session_entries) {
   1.155 -        Isabelle_System.with_tmp_file(session, "data") { data_file =>
   1.156 -          Isabelle_System.with_tmp_file(session, "gnuplot") { gnuplot_file =>
   1.157 -
   1.158 -            File.write(data_file,
   1.159 -              cat_lines(
   1.160 -                entries.map(entry =>
   1.161 -                  List(entry.date.unix_epoch.toString,
   1.162 -                    entry.timing.elapsed.minutes,
   1.163 -                    entry.timing.cpu.minutes,
   1.164 -                    entry.ml_timing.elapsed.minutes,
   1.165 -                    entry.ml_timing.cpu.minutes,
   1.166 -                    entry.ml_timing.gc.minutes).mkString(" "))))
   1.167 -
   1.168 -            val plots1 =
   1.169 -              List(
   1.170 -                """ using 1:3 smooth sbezier title "cpu time (smooth)" """,
   1.171 -                """ using 1:3 smooth csplines title "cpu time" """,
   1.172 -                """ using 1:2 smooth sbezier title "elapsed time (smooth)" """,
   1.173 -                """ using 1:2 smooth csplines title "elapsed time" """)
   1.174 -            val plots2 =
   1.175 -              List(
   1.176 -                """ using 1:5 smooth sbezier title "ML cpu time (smooth)" """,
   1.177 -                """ using 1:5 smooth csplines title "ML cpu time" """,
   1.178 -                """ using 1:4 smooth sbezier title "ML elapsed time (smooth)" """,
   1.179 -                """ using 1:4 smooth csplines title "ML elapsed time" """,
   1.180 -                """ using 1:6 smooth sbezier title "ML gc time (smooth)" """,
   1.181 -                """ using 1:6 smooth csplines title "ML gc time" """)
   1.182 -            val plots =
   1.183 -              ml_timing match {
   1.184 -                case None => plots1
   1.185 -                case Some(false) => plots1 ::: plots2
   1.186 -                case Some(true) => plots2
   1.187 -              }
   1.188 -
   1.189 -            File.write(gnuplot_file, """
   1.190 -set terminal png size """ + image_size._1 + "," + image_size._2 + """
   1.191 -set output """ + quote(File.standard_path(dir + Path.basic(session + ".png"))) + """
   1.192 -set xdata time
   1.193 -set timefmt "%s"
   1.194 -set format x "%d-%b"
   1.195 -set xlabel """ + quote(session) + """ noenhanced
   1.196 -set key left top
   1.197 -plot [] [0:] """ + plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n")
   1.198 -
   1.199 -            val result =
   1.200 -              Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file))
   1.201 -            if (result.rc != 0)
   1.202 -              result.error("Gnuplot failed for " + name + "/" + session).check
   1.203 -          }
   1.204 -        }
   1.205 -      }
   1.206 -
   1.207 -      File.write(dir + Path.basic("index.html"),
   1.208 -        html_header + "\n<h1>" + HTML.output(name) + "</h1>\n" +
   1.209 -        cat_lines(
   1.210 -          session_entries.toList.map(_._1).sorted.map(session =>
   1.211 -            """<br/><img src=""" + quote(HTML.output(session + ".png")) + """><br/>""")) +
   1.212 -        "\n" + html_footer)
   1.213 -    }
   1.214 -
   1.215 -    File.write(target_dir + Path.basic("index.html"),
   1.216 -      html_header + "\n<ul>\n" +
   1.217 -      cat_lines(
   1.218 -        data_entries.map(_._1).map(name =>
   1.219 -          """<li> <a href=""" + quote(HTML.output(name + "/index.html")) + """>""" +
   1.220 -            HTML.output(name) + """</a> </li>""")) +
   1.221 -      "\n</ul>\n" + html_footer)
   1.222 -  }
   1.223 -
   1.224 -
   1.225 -  /* Isabelle tool wrapper */
   1.226 -
   1.227 -  val isabelle_tool =
   1.228 -    Isabelle_Tool("build_stats", "present statistics from build log database", args =>
   1.229 -    {
   1.230 -      var target_dir = default_target_dir
   1.231 -      var ml_timing: Option[Boolean] = None
   1.232 -      var only_sessions = Set.empty[String]
   1.233 -      var elapsed_threshold = Time.zero
   1.234 -      var history_length = default_history_length
   1.235 -      var options = Options.init()
   1.236 -      var image_size = default_image_size
   1.237 -
   1.238 -      val getopts = Getopts("""
   1.239 -Usage: isabelle build_stats [OPTIONS]
   1.240 -
   1.241 -  Options are:
   1.242 -    -D DIR       target directory (default """ + default_target_dir + """)
   1.243 -    -M           only ML timing
   1.244 -    -S SESSIONS  only given SESSIONS (comma separated)
   1.245 -    -T THRESHOLD only sessions with elapsed time >= THRESHOLD (minutes)
   1.246 -    -l LENGTH    length of history (default """ + default_history_length + """)
   1.247 -    -m           include ML timing
   1.248 -    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
   1.249 -    -s WxH       size of PNG image (default """ + image_size._1 + "x" + image_size._2 + """)
   1.250 -
   1.251 -  Present performance statistics from build log database, which is specified
   1.252 -  via system options build_log_database_host, build_log_database_user etc.
   1.253 -""",
   1.254 -        "D:" -> (arg => target_dir = Path.explode(arg)),
   1.255 -        "M" -> (_ => ml_timing = Some(true)),
   1.256 -        "S:" -> (arg => only_sessions = space_explode(',', arg).toSet),
   1.257 -        "T:" -> (arg => elapsed_threshold = Time.minutes(Value.Double.parse(arg))),
   1.258 -        "l:" -> (arg => history_length = Value.Int.parse(arg)),
   1.259 -        "m" -> (_ => ml_timing = Some(false)),
   1.260 -        "o:" -> (arg => options = options + arg),
   1.261 -        "s:" -> (arg =>
   1.262 -          space_explode('x', arg).map(Value.Int.parse(_)) match {
   1.263 -            case List(w, h) if w > 0 && h > 0 => image_size = (w, h)
   1.264 -            case _ => error("Error bad PNG image size: " + quote(arg))
   1.265 -          }))
   1.266 -
   1.267 -      val more_args = getopts(args)
   1.268 -      if (more_args.nonEmpty) getopts.usage()
   1.269 -
   1.270 -      val progress = new Console_Progress
   1.271 -
   1.272 -      val data =
   1.273 -        read_data(options, profiles = standard_profiles, progress = progress,
   1.274 -          history_length = history_length, only_sessions = only_sessions,
   1.275 -          elapsed_threshold = elapsed_threshold)
   1.276 -
   1.277 -      present_data(data, progress = progress, target_dir = target_dir,
   1.278 -        image_size = image_size, ml_timing = ml_timing)
   1.279 -
   1.280 -  }, admin = true)
   1.281 -}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/Pure/Admin/build_status.scala	Sat May 06 19:23:33 2017 +0200
     2.3 @@ -0,0 +1,278 @@
     2.4 +/*  Title:      Pure/Admin/build_status.scala
     2.5 +    Author:     Makarius
     2.6 +
     2.7 +Present recent build status information from database.
     2.8 +*/
     2.9 +
    2.10 +package isabelle
    2.11 +
    2.12 +
    2.13 +object Build_Status
    2.14 +{
    2.15 +  private val default_target_dir = Path.explode("build_status")
    2.16 +  private val default_history_length = 30
    2.17 +  private val default_image_size = (800, 600)
    2.18 +
    2.19 +
    2.20 +  /* data profiles */
    2.21 +
    2.22 +  sealed case class Profile(name: String, sql: String)
    2.23 +  {
    2.24 +    def select(columns: List[SQL.Column], days: Int, only_sessions: Set[String]): SQL.Source =
    2.25 +    {
    2.26 +      val sql_sessions =
    2.27 +        if (only_sessions.isEmpty) ""
    2.28 +        else
    2.29 +          only_sessions.iterator.map(a => Build_Log.Data.session_name + " = " + SQL.string(a))
    2.30 +            .mkString("(", " OR ", ") AND ")
    2.31 +
    2.32 +      Build_Log.Data.universal_table.select(columns, distinct = true,
    2.33 +        sql = "WHERE " +
    2.34 +          Build_Log.Data.pull_date + " > " + Build_Log.Data.recent_time(days) + " AND " +
    2.35 +          Build_Log.Data.status + " = " + SQL.string(Build_Log.Session_Status.finished.toString) +
    2.36 +          " AND " + sql_sessions + SQL.enclose(sql) +
    2.37 +          " ORDER BY " + Build_Log.Data.pull_date + " DESC")
    2.38 +    }
    2.39 +  }
    2.40 +
    2.41 +  val standard_profiles: List[Profile] =
    2.42 +    Jenkins.build_log_profiles :::
    2.43 +    Isabelle_Cronjob.remote_builds.flatten.toList.map(r => Profile(r.name, r.sql))
    2.44 +
    2.45 +  sealed case class Entry(date: Date, timing: Timing, ml_timing: Timing)
    2.46 +  {
    2.47 +    def check(elapsed_threshold: Time): Boolean =
    2.48 +      !timing.is_zero && timing.elapsed >= elapsed_threshold
    2.49 +  }
    2.50 +
    2.51 +  type Data = Map[String, Map[String, List[Entry]]]
    2.52 +
    2.53 +
    2.54 +  /* read data */
    2.55 +
    2.56 +  def read_data(options: Options,
    2.57 +    profiles: List[Profile] = standard_profiles,
    2.58 +    progress: Progress = No_Progress,
    2.59 +    history_length: Int = default_history_length,
    2.60 +    only_sessions: Set[String] = Set.empty,
    2.61 +    elapsed_threshold: Time = Time.zero): Data =
    2.62 +  {
    2.63 +    var data: Data = Map.empty
    2.64 +
    2.65 +    val store = Build_Log.store(options)
    2.66 +    using(store.open_database())(db =>
    2.67 +    {
    2.68 +      for (profile <- profiles) {
    2.69 +        progress.echo("input " + quote(profile.name))
    2.70 +        val columns =
    2.71 +          List(
    2.72 +            Build_Log.Data.pull_date,
    2.73 +            Build_Log.Settings.ML_PLATFORM,
    2.74 +            Build_Log.Data.session_name,
    2.75 +            Build_Log.Data.threads,
    2.76 +            Build_Log.Data.timing_elapsed,
    2.77 +            Build_Log.Data.timing_cpu,
    2.78 +            Build_Log.Data.timing_gc,
    2.79 +            Build_Log.Data.ml_timing_elapsed,
    2.80 +            Build_Log.Data.ml_timing_cpu,
    2.81 +            Build_Log.Data.ml_timing_gc)
    2.82 +
    2.83 +        db.using_statement(profile.select(columns, history_length, only_sessions))(stmt =>
    2.84 +        {
    2.85 +          val res = stmt.execute_query()
    2.86 +          while (res.next()) {
    2.87 +            val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM)
    2.88 +            val threads = res.get_int(Build_Log.Data.threads)
    2.89 +            val name =
    2.90 +              profile.name +
    2.91 +                "_m" + (if (ml_platform.startsWith("x86_64")) "64" else "32") +
    2.92 +                "_M" + threads.getOrElse(1)
    2.93 +
    2.94 +            val session = res.string(Build_Log.Data.session_name)
    2.95 +            val entry =
    2.96 +              Entry(res.date(Build_Log.Data.pull_date),
    2.97 +                res.timing(
    2.98 +                  Build_Log.Data.timing_elapsed,
    2.99 +                  Build_Log.Data.timing_cpu,
   2.100 +                  Build_Log.Data.timing_gc),
   2.101 +                res.timing(
   2.102 +                  Build_Log.Data.ml_timing_elapsed,
   2.103 +                  Build_Log.Data.ml_timing_cpu,
   2.104 +                  Build_Log.Data.ml_timing_gc))
   2.105 +
   2.106 +            val session_entries = data.getOrElse(name, Map.empty)
   2.107 +            val entries = session_entries.getOrElse(session, Nil)
   2.108 +            data += (name -> (session_entries + (session -> (entry :: entries))))
   2.109 +          }
   2.110 +        })
   2.111 +      }
   2.112 +    })
   2.113 +
   2.114 +    for {
   2.115 +      (name, session_entries) <- data
   2.116 +      session_entries1 <-
   2.117 +        {
   2.118 +          val session_entries1 =
   2.119 +            for {
   2.120 +              (session, entries) <- session_entries
   2.121 +              if entries.filter(_.check(elapsed_threshold)).length >= 3
   2.122 +            } yield (session, entries)
   2.123 +          if (session_entries1.isEmpty) None
   2.124 +          else Some(session_entries1)
   2.125 +        }
   2.126 +    } yield (name, session_entries1)
   2.127 +  }
   2.128 +
   2.129 +
   2.130 +  /* present data */
   2.131 +
   2.132 +  private val html_header = """<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
   2.133 +<html>
   2.134 +<head><title>Build status</title></head>
   2.135 +<body>
   2.136 +"""
   2.137 +  private val html_footer = """
   2.138 +</body>
   2.139 +</html>
   2.140 +"""
   2.141 +
   2.142 +  def present_data(data: Data,
   2.143 +    progress: Progress = No_Progress,
   2.144 +    target_dir: Path = default_target_dir,
   2.145 +    image_size: (Int, Int) = default_image_size,
   2.146 +    ml_timing: Option[Boolean] = None)
   2.147 +  {
   2.148 +    val data_entries = data.toList.sortBy(_._1)
   2.149 +    for ((name, session_entries) <- data_entries) {
   2.150 +      val dir = target_dir + Path.explode(name)
   2.151 +      progress.echo("output " + dir)
   2.152 +      Isabelle_System.mkdirs(dir)
   2.153 +
   2.154 +      for ((session, entries) <- session_entries) {
   2.155 +        Isabelle_System.with_tmp_file(session, "data") { data_file =>
   2.156 +          Isabelle_System.with_tmp_file(session, "gnuplot") { gnuplot_file =>
   2.157 +
   2.158 +            File.write(data_file,
   2.159 +              cat_lines(
   2.160 +                entries.map(entry =>
   2.161 +                  List(entry.date.unix_epoch.toString,
   2.162 +                    entry.timing.elapsed.minutes,
   2.163 +                    entry.timing.cpu.minutes,
   2.164 +                    entry.ml_timing.elapsed.minutes,
   2.165 +                    entry.ml_timing.cpu.minutes,
   2.166 +                    entry.ml_timing.gc.minutes).mkString(" "))))
   2.167 +
   2.168 +            val plots1 =
   2.169 +              List(
   2.170 +                """ using 1:3 smooth sbezier title "cpu time (smooth)" """,
   2.171 +                """ using 1:3 smooth csplines title "cpu time" """,
   2.172 +                """ using 1:2 smooth sbezier title "elapsed time (smooth)" """,
   2.173 +                """ using 1:2 smooth csplines title "elapsed time" """)
   2.174 +            val plots2 =
   2.175 +              List(
   2.176 +                """ using 1:5 smooth sbezier title "ML cpu time (smooth)" """,
   2.177 +                """ using 1:5 smooth csplines title "ML cpu time" """,
   2.178 +                """ using 1:4 smooth sbezier title "ML elapsed time (smooth)" """,
   2.179 +                """ using 1:4 smooth csplines title "ML elapsed time" """,
   2.180 +                """ using 1:6 smooth sbezier title "ML gc time (smooth)" """,
   2.181 +                """ using 1:6 smooth csplines title "ML gc time" """)
   2.182 +            val plots =
   2.183 +              ml_timing match {
   2.184 +                case None => plots1
   2.185 +                case Some(false) => plots1 ::: plots2
   2.186 +                case Some(true) => plots2
   2.187 +              }
   2.188 +
   2.189 +            File.write(gnuplot_file, """
   2.190 +set terminal png size """ + image_size._1 + "," + image_size._2 + """
   2.191 +set output """ + quote(File.standard_path(dir + Path.basic(session + ".png"))) + """
   2.192 +set xdata time
   2.193 +set timefmt "%s"
   2.194 +set format x "%d-%b"
   2.195 +set xlabel """ + quote(session) + """ noenhanced
   2.196 +set key left top
   2.197 +plot [] [0:] """ + plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n")
   2.198 +
   2.199 +            val result =
   2.200 +              Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file))
   2.201 +            if (result.rc != 0)
   2.202 +              result.error("Gnuplot failed for " + name + "/" + session).check
   2.203 +          }
   2.204 +        }
   2.205 +      }
   2.206 +
   2.207 +      File.write(dir + Path.basic("index.html"),
   2.208 +        html_header + "\n<h1>" + HTML.output(name) + "</h1>\n" +
   2.209 +        cat_lines(
   2.210 +          session_entries.toList.map(_._1).sorted.map(session =>
   2.211 +            """<br/><img src=""" + quote(HTML.output(session + ".png")) + """><br/>""")) +
   2.212 +        "\n" + html_footer)
   2.213 +    }
   2.214 +
   2.215 +    File.write(target_dir + Path.basic("index.html"),
   2.216 +      html_header + "\n<ul>\n" +
   2.217 +      cat_lines(
   2.218 +        data_entries.map(_._1).map(name =>
   2.219 +          """<li> <a href=""" + quote(HTML.output(name + "/index.html")) + """>""" +
   2.220 +            HTML.output(name) + """</a> </li>""")) +
   2.221 +      "\n</ul>\n" + html_footer)
   2.222 +  }
   2.223 +
   2.224 +
   2.225 +  /* Isabelle tool wrapper */
   2.226 +
   2.227 +  val isabelle_tool =
   2.228 +    Isabelle_Tool("build_status", "present recent build status information from database", args =>
   2.229 +    {
   2.230 +      var target_dir = default_target_dir
   2.231 +      var ml_timing: Option[Boolean] = None
   2.232 +      var only_sessions = Set.empty[String]
   2.233 +      var elapsed_threshold = Time.zero
   2.234 +      var history_length = default_history_length
   2.235 +      var options = Options.init()
   2.236 +      var image_size = default_image_size
   2.237 +
   2.238 +      val getopts = Getopts("""
   2.239 +Usage: isabelle build_status [OPTIONS]
   2.240 +
   2.241 +  Options are:
   2.242 +    -D DIR       target directory (default """ + default_target_dir + """)
   2.243 +    -M           only ML timing
   2.244 +    -S SESSIONS  only given SESSIONS (comma separated)
   2.245 +    -T THRESHOLD only sessions with elapsed time >= THRESHOLD (minutes)
   2.246 +    -l LENGTH    length of history (default """ + default_history_length + """)
   2.247 +    -m           include ML timing
   2.248 +    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
   2.249 +    -s WxH       size of PNG image (default """ + image_size._1 + "x" + image_size._2 + """)
   2.250 +
   2.251 +  Present performance statistics from build log database, which is specified
   2.252 +  via system options build_log_database_host, build_log_database_user etc.
   2.253 +""",
   2.254 +        "D:" -> (arg => target_dir = Path.explode(arg)),
   2.255 +        "M" -> (_ => ml_timing = Some(true)),
   2.256 +        "S:" -> (arg => only_sessions = space_explode(',', arg).toSet),
   2.257 +        "T:" -> (arg => elapsed_threshold = Time.minutes(Value.Double.parse(arg))),
   2.258 +        "l:" -> (arg => history_length = Value.Int.parse(arg)),
   2.259 +        "m" -> (_ => ml_timing = Some(false)),
   2.260 +        "o:" -> (arg => options = options + arg),
   2.261 +        "s:" -> (arg =>
   2.262 +          space_explode('x', arg).map(Value.Int.parse(_)) match {
   2.263 +            case List(w, h) if w > 0 && h > 0 => image_size = (w, h)
   2.264 +            case _ => error("Error bad PNG image size: " + quote(arg))
   2.265 +          }))
   2.266 +
   2.267 +      val more_args = getopts(args)
   2.268 +      if (more_args.nonEmpty) getopts.usage()
   2.269 +
   2.270 +      val progress = new Console_Progress
   2.271 +
   2.272 +      val data =
   2.273 +        read_data(options, profiles = standard_profiles, progress = progress,
   2.274 +          history_length = history_length, only_sessions = only_sessions,
   2.275 +          elapsed_threshold = elapsed_threshold)
   2.276 +
   2.277 +      present_data(data, progress = progress, target_dir = target_dir,
   2.278 +        image_size = image_size, ml_timing = ml_timing)
   2.279 +
   2.280 +  }, admin = true)
   2.281 +}
     3.1 --- a/src/Pure/Admin/jenkins.scala	Sat May 06 12:59:16 2017 +0200
     3.2 +++ b/src/Pure/Admin/jenkins.scala	Sat May 06 19:23:33 2017 +0200
     3.3 @@ -52,9 +52,9 @@
     3.4  
     3.5    val build_log_jobs = List("isabelle-nightly-benchmark")
     3.6  
     3.7 -  val build_log_profiles: List[Build_Stats.Profile] =
     3.8 +  val build_log_profiles: List[Build_Status.Profile] =
     3.9      build_log_jobs.map(job_name =>
    3.10 -      Build_Stats.Profile("jenkins_" + job_name,
    3.11 +      Build_Status.Profile("jenkins_" + job_name,
    3.12          Build_Log.Prop.build_engine + " = " + SQL.string(Build_Log.Jenkins.engine) + " AND " +
    3.13          Build_Log.Data.log_name + " LIKE " + SQL.string("%" + job_name)))
    3.14  
     4.1 --- a/src/Pure/System/isabelle_tool.scala	Sat May 06 12:59:16 2017 +0200
     4.2 +++ b/src/Pure/System/isabelle_tool.scala	Sat May 06 19:23:33 2017 +0200
     4.3 @@ -105,7 +105,7 @@
     4.4        Build_Docker.isabelle_tool,
     4.5        Build_JDK.isabelle_tool,
     4.6        Build_PolyML.isabelle_tool,
     4.7 -      Build_Stats.isabelle_tool,
     4.8 +      Build_Status.isabelle_tool,
     4.9        Check_Sources.isabelle_tool,
    4.10        Doc.isabelle_tool,
    4.11        Imports.isabelle_tool,
     5.1 --- a/src/Pure/build-jars	Sat May 06 12:59:16 2017 +0200
     5.2 +++ b/src/Pure/build-jars	Sat May 06 19:23:33 2017 +0200
     5.3 @@ -17,8 +17,8 @@
     5.4    Admin/build_log.scala
     5.5    Admin/build_polyml.scala
     5.6    Admin/build_release.scala
     5.7 -  Admin/build_stats.scala
     5.8    Admin/build_stats_legacy.scala
     5.9 +  Admin/build_status.scala
    5.10    Admin/check_sources.scala
    5.11    Admin/ci_profile.scala
    5.12    Admin/isabelle_cronjob.scala