src/Pure/Admin/build_status.scala
author wenzelm
Sun, 07 May 2017 22:10:48 +0200
changeset 65763 dbadcc3fbe33
parent 65762 295b845243d3
child 65764 1af6d544c2a3
permissions -rw-r--r--
tuned output;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
     1
/*  Title:      Pure/Admin/build_status.scala
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     3
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
     4
Present recent build status information from database.
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     5
*/
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     6
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     7
package isabelle
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     8
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
     9
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
    10
object Build_Status
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
    11
{
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
    12
  private val default_target_dir = Path.explode("build_status")
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    13
  private val default_history_length = 30
65757
a6522bb9acfa tuned output;
wenzelm
parents: 65756
diff changeset
    14
  private val default_image_size = (640, 480)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    15
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    16
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    17
  /* data profiles */
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
    18
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    19
  sealed case class Profile(name: String, sql: String)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    20
  {
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    21
    def select(columns: List[SQL.Column], days: Int, only_sessions: Set[String]): SQL.Source =
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    22
    {
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    23
      val sql_sessions =
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    24
        if (only_sessions.isEmpty) ""
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    25
        else
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    26
          only_sessions.iterator.map(a => Build_Log.Data.session_name + " = " + SQL.string(a))
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    27
            .mkString("(", " OR ", ") AND ")
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
    28
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    29
      Build_Log.Data.universal_table.select(columns, distinct = true,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    30
        sql = "WHERE " +
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    31
          Build_Log.Data.pull_date + " > " + Build_Log.Data.recent_time(days) + " AND " +
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    32
          Build_Log.Data.status + " = " + SQL.string(Build_Log.Session_Status.finished.toString) +
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    33
          " AND " + sql_sessions + SQL.enclose(sql) +
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    34
          " ORDER BY " + Build_Log.Data.pull_date + " DESC")
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    35
    }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    36
  }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    37
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    38
  val standard_profiles: List[Profile] =
65747
5a3052b2095f tuned signature;
wenzelm
parents: 65745
diff changeset
    39
    Jenkins.build_status_profiles ::: Isabelle_Cronjob.build_status_profiles
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    40
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    41
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    42
  sealed case class Data(date: Date, entries: List[(String, List[Session])])
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    43
  sealed case class Session(name: String, entries: List[Entry])
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
    44
  {
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    45
    def timing: Timing = if (entries.isEmpty) Timing.zero else entries.head.timing
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    46
    def ml_timing: Timing = if (entries.isEmpty) Timing.zero else entries.head.ml_timing
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    47
    def order: Long = - timing.elapsed.ms
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    48
    def check: Boolean = entries.length >= 3
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
    49
  }
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    50
  sealed case class Entry(date: Date, timing: Timing, ml_timing: Timing)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    51
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
    52
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    53
  /* read data */
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    54
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    55
  def read_data(options: Options,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    56
    profiles: List[Profile] = standard_profiles,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    57
    progress: Progress = No_Progress,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    58
    history_length: Int = default_history_length,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    59
    only_sessions: Set[String] = Set.empty,
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
    60
    verbose: Boolean = false): Data =
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    61
  {
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
    62
    val date = Date.now()
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
    63
    var data_entries = Map.empty[String, Map[String, Session]]
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
    64
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    65
    val store = Build_Log.store(options)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    66
    using(store.open_database())(db =>
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64085
diff changeset
    67
    {
65751
wenzelm
parents: 65750
diff changeset
    68
      for (profile <- profiles.sortBy(_.name)) {
65742
b9e0f25ba16a tuned messages;
wenzelm
parents: 65741
diff changeset
    69
        progress.echo("input " + quote(profile.name))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    70
        val columns =
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    71
          List(
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    72
            Build_Log.Data.pull_date,
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    73
            Build_Log.Settings.ISABELLE_BUILD_OPTIONS,
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    74
            Build_Log.Settings.ML_PLATFORM,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    75
            Build_Log.Data.session_name,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    76
            Build_Log.Data.threads,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    77
            Build_Log.Data.timing_elapsed,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    78
            Build_Log.Data.timing_cpu,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    79
            Build_Log.Data.timing_gc,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    80
            Build_Log.Data.ml_timing_elapsed,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    81
            Build_Log.Data.ml_timing_cpu,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    82
            Build_Log.Data.ml_timing_gc)
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
    83
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    84
        val Threads_Option = """threads\s*=\s*(\d+)""".r
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    85
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
    86
        val sql = profile.select(columns, history_length, only_sessions)
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
    87
        if (verbose) progress.echo(sql)
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
    88
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
    89
        db.using_statement(sql)(stmt =>
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
    90
        {
65740
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
    91
          val res = stmt.execute_query()
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
    92
          while (res.next()) {
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
    93
            val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM)
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    94
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    95
            val threads_option =
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    96
              res.string(Build_Log.Settings.ISABELLE_BUILD_OPTIONS) match {
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    97
                case Threads_Option(Value.Int(i)) => i
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    98
                case _ => 1
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
    99
              }
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   100
            val threads = res.get_int(Build_Log.Data.threads).getOrElse(1)
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   101
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   102
            val data_name =
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   103
              profile.name +
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   104
                "_m" + (if (ml_platform.startsWith("x86_64")) "64" else "32") +
65752
ed7b5cd3a7f2 more uniform threads value, notably for Pure session;
wenzelm
parents: 65751
diff changeset
   105
                "_M" + (threads_option max threads)
63703
ec095a532a2b provide index.html;
wenzelm
parents: 63702
diff changeset
   106
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   107
            val name = res.string(Build_Log.Data.session_name)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   108
            val entry =
65740
83388f09e9ab clarified signature;
wenzelm
parents: 65737
diff changeset
   109
              Entry(res.date(Build_Log.Data.pull_date),
65741
wenzelm
parents: 65740
diff changeset
   110
                res.timing(
wenzelm
parents: 65740
diff changeset
   111
                  Build_Log.Data.timing_elapsed,
wenzelm
parents: 65740
diff changeset
   112
                  Build_Log.Data.timing_cpu,
wenzelm
parents: 65740
diff changeset
   113
                  Build_Log.Data.timing_gc),
wenzelm
parents: 65740
diff changeset
   114
                res.timing(
wenzelm
parents: 65740
diff changeset
   115
                  Build_Log.Data.ml_timing_elapsed,
wenzelm
parents: 65740
diff changeset
   116
                  Build_Log.Data.ml_timing_cpu,
wenzelm
parents: 65740
diff changeset
   117
                  Build_Log.Data.ml_timing_gc))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   118
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   119
            val sessions = data_entries.getOrElse(data_name, Map.empty)
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   120
            val entries = sessions.get(name).map(_.entries) getOrElse Nil
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   121
            data_entries += (data_name -> (sessions + (name -> Session(name, entry :: entries))))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   122
          }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   123
        })
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   124
      }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   125
    })
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   126
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   127
    Data(date,
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   128
      (for {
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   129
        (data_name, sessions) <- data_entries.toList
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   130
        sorted_sessions <- proper_list(sessions.toList.map(_._2).filter(_.check).sortBy(_.order))
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   131
      } yield (data_name, sorted_sessions)).sortBy(_._1))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   132
  }
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   133
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   134
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   135
  /* present data */
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   136
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   137
  def present_data(data: Data,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   138
    progress: Progress = No_Progress,
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   139
    target_dir: Path = default_target_dir,
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   140
    image_size: (Int, Int) = default_image_size)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   141
  {
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   142
    for ((data_name, sessions) <- data.entries) {
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   143
      val dir = target_dir + Path.explode(data_name)
65742
b9e0f25ba16a tuned messages;
wenzelm
parents: 65741
diff changeset
   144
      progress.echo("output " + dir)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   145
      Isabelle_System.mkdirs(dir)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   146
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   147
      Par_List.map[Session, List[Process_Result]]((session: Session) =>
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   148
        Isabelle_System.with_tmp_file(session.name, "data") { data_file =>
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   149
          Isabelle_System.with_tmp_file(session.name, "gnuplot") { gnuplot_file =>
63706
76c2f833abf4 present ML timing as well;
wenzelm
parents: 63703
diff changeset
   150
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   151
            File.write(data_file,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   152
              cat_lines(
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   153
                session.entries.map(entry =>
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   154
                  List(entry.date.unix_epoch.toString,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   155
                    entry.timing.elapsed.minutes,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   156
                    entry.timing.resources.minutes,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   157
                    entry.ml_timing.elapsed.minutes,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   158
                    entry.ml_timing.resources.minutes).mkString(" "))))
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   159
65763
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   160
            val max_time =
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   161
              ((0.0 /: session.entries){ case (m, entry) =>
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   162
                m.max(entry.timing.elapsed.minutes).
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   163
                  max(entry.timing.resources.minutes).
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   164
                  max(entry.ml_timing.elapsed.minutes).
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   165
                  max(entry.ml_timing.resources.minutes) } max 0.1) * 1.1
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   166
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   167
            def gnuplot(plots: List[String], kind: String): Process_Result =
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   168
            {
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   169
              val name = session.name + "_" + kind
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   170
              File.write(gnuplot_file, """
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   171
set terminal png size """ + image_size._1 + "," + image_size._2 + """
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   172
set output """ + quote(File.standard_path(dir + Path.basic(name + ".png"))) + """
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   173
set xdata time
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   174
set timefmt "%s"
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   175
set format x "%d-%b"
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   176
set xlabel """ + quote(session.name) + """ noenhanced
65763
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   177
set key left bottom
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   178
plot [] [0:""" + max_time + "] " +
dbadcc3fbe33 tuned output;
wenzelm
parents: 65762
diff changeset
   179
                plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n")
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   180
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   181
              val result =
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   182
                Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file))
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   183
              if (result.ok) result
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   184
              else result.error("Gnuplot failed for " + data_name + "/" + name)
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   185
            }
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   186
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   187
            val timing_plots =
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   188
              List(
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   189
                """ using 1:3 smooth sbezier title "cpu time (smooth)" """,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   190
                """ using 1:3 smooth csplines title "cpu time" """,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   191
                """ using 1:2 smooth sbezier title "elapsed time (smooth)" """,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   192
                """ using 1:2 smooth csplines title "elapsed time" """)
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   193
            val ml_timing_plots =
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   194
              List(
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   195
                """ using 1:5 smooth sbezier title "ML cpu time (smooth)" """,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   196
                """ using 1:5 smooth csplines title "ML cpu time" """,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   197
                """ using 1:4 smooth sbezier title "ML elapsed time (smooth)" """,
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   198
                """ using 1:4 smooth csplines title "ML elapsed time" """)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   199
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   200
            List(gnuplot(timing_plots, "timing"), gnuplot(ml_timing_plots, "ml_timing"))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   201
          }
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   202
        }, sessions).flatten.foreach(_.check)
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   203
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   204
      File.write(dir + Path.basic("index.html"),
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   205
        HTML.output_document(
65760
a51290fd62d9 more uniform charts;
wenzelm
parents: 65759
diff changeset
   206
          List(HTML.title("Isabelle build status for " + data_name)),
a51290fd62d9 more uniform charts;
wenzelm
parents: 65759
diff changeset
   207
          HTML.chapter("Isabelle build status for " + data_name + " (" + data.date + ")") ::
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   208
          HTML.itemize(
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   209
            sessions.map(session =>
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   210
              HTML.link("#session_" + session.name, HTML.text(session.name)) ::
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   211
              HTML.text(" (" + session.timing.message_resources + ")"))) ::
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   212
          sessions.flatMap(session =>
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   213
            List(
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   214
              HTML.section(session.name) + HTML.id("session_" + session.name),
65755
21b4bfa6d204 more HTML output;
wenzelm
parents: 65754
diff changeset
   215
              HTML.par(
21b4bfa6d204 more HTML output;
wenzelm
parents: 65754
diff changeset
   216
                List(
21b4bfa6d204 more HTML output;
wenzelm
parents: 65754
diff changeset
   217
                  HTML.itemize(List(
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   218
                    HTML.bold(HTML.text("timing: ")) :: HTML.text(session.timing.message_resources),
65757
a6522bb9acfa tuned output;
wenzelm
parents: 65756
diff changeset
   219
                    HTML.bold(HTML.text("ML timing: ")) ::
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   220
                      HTML.text(session.ml_timing.message_resources))),
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   221
                  HTML.image(session.name + "_timing.png"),
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   222
                  HTML.image(session.name + "_ml_timing.png")))))))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   223
    }
63703
ec095a532a2b provide index.html;
wenzelm
parents: 63702
diff changeset
   224
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   225
    File.write(target_dir + Path.basic("index.html"),
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   226
      HTML.output_document(
65760
a51290fd62d9 more uniform charts;
wenzelm
parents: 65759
diff changeset
   227
        List(HTML.title("Isabelle build status")),
a51290fd62d9 more uniform charts;
wenzelm
parents: 65759
diff changeset
   228
        List(HTML.chapter("Isabelle build status (" + data.date + ")"),
65762
295b845243d3 clarified types;
wenzelm
parents: 65760
diff changeset
   229
          HTML.itemize(data.entries.map({ case (name, _) =>
65754
05c6a29c9132 clarified explicit Build_Status.Data operations;
wenzelm
parents: 65752
diff changeset
   230
            List(HTML.link(name + "/index.html", HTML.text(name))) })))))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   231
  }
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   232
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   233
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   234
  /* Isabelle tool wrapper */
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   235
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   236
  val isabelle_tool =
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
   237
    Isabelle_Tool("build_status", "present recent build status information from database", args =>
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   238
    {
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   239
      var target_dir = default_target_dir
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   240
      var only_sessions = Set.empty[String]
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   241
      var history_length = default_history_length
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   242
      var options = Options.init()
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   243
      var image_size = default_image_size
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   244
      var verbose = false
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   245
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   246
      val getopts = Getopts("""
65743
4847ca570454 clarified name;
wenzelm
parents: 65742
diff changeset
   247
Usage: isabelle build_status [OPTIONS]
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   248
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   249
  Options are:
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   250
    -D DIR       target directory (default """ + default_target_dir + """)
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   251
    -S SESSIONS  only given SESSIONS (comma separated)
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   252
    -l LENGTH    length of history (default """ + default_history_length + """)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   253
    -o OPTION    override Isabelle system OPTION (via NAME=VAL or NAME)
65737
0729c09be90c tuned messages;
wenzelm
parents: 65736
diff changeset
   254
    -s WxH       size of PNG image (default """ + image_size._1 + "x" + image_size._2 + """)
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   255
    -v           verbose
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   256
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   257
  Present performance statistics from build log database, which is specified
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   258
  via system options build_log_database_host, build_log_database_user etc.
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   259
""",
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   260
        "D:" -> (arg => target_dir = Path.explode(arg)),
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   261
        "S:" -> (arg => only_sessions = space_explode(',', arg).toSet),
63805
c272680df665 clarified modules;
wenzelm
parents: 63708
diff changeset
   262
        "l:" -> (arg => history_length = Value.Int.parse(arg)),
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   263
        "o:" -> (arg => options = options + arg),
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   264
        "s:" -> (arg =>
63805
c272680df665 clarified modules;
wenzelm
parents: 63708
diff changeset
   265
          space_explode('x', arg).map(Value.Int.parse(_)) match {
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   266
            case List(w, h) if w > 0 && h > 0 => image_size = (w, h)
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   267
            case _ => error("Error bad PNG image size: " + quote(arg))
65750
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   268
          }),
7f5556f4b584 added option verbose for SQL source;
wenzelm
parents: 65747
diff changeset
   269
        "v" -> (_ => verbose = true))
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   270
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   271
      val more_args = getopts(args)
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   272
      if (more_args.nonEmpty) getopts.usage()
63700
2a95d904672e clarified options and arguments;
wenzelm
parents: 63688
diff changeset
   273
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   274
      val progress = new Console_Progress
63688
cc57255bf6ae gnuplot presentation similar to former isatest-statistics;
wenzelm
parents: 63686
diff changeset
   275
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   276
      val data =
65745
wenzelm
parents: 65743
diff changeset
   277
        read_data(options, progress = progress, history_length = history_length,
65758
d79126bb5d07 removed threshold: redundant due to sorting;
wenzelm
parents: 65757
diff changeset
   278
          only_sessions = only_sessions, verbose = verbose)
63703
ec095a532a2b provide index.html;
wenzelm
parents: 63702
diff changeset
   279
65759
a2b041a36523 always show ml_timing -- in another chart;
wenzelm
parents: 65758
diff changeset
   280
      present_data(data, progress = progress, target_dir = target_dir, image_size = image_size)
65736
2e7230b66a32 performance statistics from build log database;
wenzelm
parents: 65733
diff changeset
   281
64161
2b1128e95dfb explicit indication of Admin tools;
wenzelm
parents: 64106
diff changeset
   282
  }, admin = true)
63686
66f217416da7 statistics from session build output;
wenzelm
parents:
diff changeset
   283
}