author | wenzelm |
Wed, 18 Oct 2017 20:26:32 +0200 | |
changeset 66882 | 2d98b0141d89 |
parent 66881 | e7635ea96988 |
child 66980 | 8947cf58cb86 |
permissions | -rw-r--r-- |
65743 | 1 |
/* Title: Pure/Admin/build_status.scala |
63686 | 2 |
Author: Makarius |
3 |
||
65743 | 4 |
Present recent build status information from database. |
63686 | 5 |
*/ |
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
65743 | 10 |
object Build_Status |
63686 | 11 |
{ |
65799 | 12 |
/* defaults */ |
13 |
||
14 |
val default_target_dir = Path.explode("build_status") |
|
15 |
val default_image_size = (800, 600) |
|
16 |
val default_history = 30 |
|
17 |
||
18 |
def default_profiles: List[Profile] = |
|
19 |
Jenkins.build_status_profiles ::: Isabelle_Cronjob.build_status_profiles |
|
20 |
||
21 |
||
65791 | 22 |
/* data profiles */ |
23 |
||
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
24 |
sealed case class Profile( |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
25 |
description: String, history: Int = 0, afp: Boolean = false, sql: String) |
65791 | 26 |
{ |
65799 | 27 |
def days(options: Options): Int = options.int("build_log_history") max history |
28 |
||
29 |
def stretch(options: Options): Double = |
|
30 |
(days(options) max default_history min (default_history * 5)).toDouble / default_history |
|
31 |
||
32 |
def select(options: Options, columns: List[SQL.Column], only_sessions: Set[String]): SQL.Source = |
|
65791 | 33 |
{ |
34 |
Build_Log.Data.universal_table.select(columns, distinct = true, |
|
35 |
sql = "WHERE " + |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
36 |
Build_Log.Data.pull_date(afp) + " > " + Build_Log.Data.recent_time(days(options)) + |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
37 |
" AND " + |
65893 | 38 |
SQL.member(Build_Log.Data.status.ident, |
39 |
List( |
|
40 |
Build_Log.Session_Status.finished.toString, |
|
41 |
Build_Log.Session_Status.failed.toString)) + |
|
65804 | 42 |
(if (only_sessions.isEmpty) "" |
43 |
else " AND " + SQL.member(Build_Log.Data.session_name.ident, only_sessions)) + |
|
44 |
" AND " + SQL.enclose(sql) + |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
45 |
" ORDER BY " + Build_Log.Data.pull_date(afp)) |
65791 | 46 |
} |
47 |
} |
|
48 |
||
49 |
||
65785 | 50 |
/* build status */ |
51 |
||
52 |
def build_status(options: Options, |
|
53 |
progress: Progress = No_Progress, |
|
54 |
profiles: List[Profile] = default_profiles, |
|
55 |
only_sessions: Set[String] = Set.empty, |
|
56 |
verbose: Boolean = false, |
|
57 |
target_dir: Path = default_target_dir, |
|
65854 | 58 |
ml_statistics: Boolean = false, |
65785 | 59 |
image_size: (Int, Int) = default_image_size) |
60 |
{ |
|
61 |
val data = |
|
62 |
read_data(options, progress = progress, profiles = profiles, |
|
65854 | 63 |
only_sessions = only_sessions, ml_statistics = ml_statistics, verbose = verbose) |
65785 | 64 |
|
65 |
present_data(data, progress = progress, target_dir = target_dir, image_size = image_size) |
|
66 |
} |
|
65736 | 67 |
|
68 |
||
65791 | 69 |
/* read data */ |
65736 | 70 |
|
65792 | 71 |
sealed case class Data(date: Date, entries: List[Data_Entry]) |
65799 | 72 |
sealed case class Data_Entry( |
73 |
name: String, hosts: List[String], stretch: Double, sessions: List[Session]) |
|
65893 | 74 |
{ |
75 |
def failed_sessions: List[Session] = |
|
76 |
sessions.filter(_.head.failed).sortBy(_.name) |
|
77 |
} |
|
65865 | 78 |
sealed case class Session( |
79 |
name: String, threads: Int, entries: List[Entry], ml_statistics: ML_Statistics) |
|
65754 | 80 |
{ |
65795 | 81 |
require(entries.nonEmpty) |
82 |
||
65863 | 83 |
def head: Entry = entries.head |
84 |
def order: Long = - head.timing.elapsed.ms |
|
65860 | 85 |
|
65893 | 86 |
def finished_entries: List[Entry] = entries.filter(_.finished) |
66254 | 87 |
def finished_entries_size: Int = |
88 |
finished_entries.map(entry => entry.pull_date.unix_epoch).toSet.size |
|
65893 | 89 |
|
66254 | 90 |
def check_timing: Boolean = finished_entries_size >= 3 |
65854 | 91 |
def check_heap: Boolean = |
66254 | 92 |
finished_entries_size >= 3 && |
65893 | 93 |
finished_entries.forall(entry => |
65859 | 94 |
entry.maximum_heap > 0 || |
95 |
entry.average_heap > 0 || |
|
65866 | 96 |
entry.stored_heap > 0) |
65754 | 97 |
} |
65854 | 98 |
sealed case class Entry( |
66881 | 99 |
chapter: String, |
65854 | 100 |
pull_date: Date, |
101 |
isabelle_version: String, |
|
102 |
afp_version: String, |
|
103 |
timing: Timing, |
|
104 |
ml_timing: Timing, |
|
65859 | 105 |
maximum_heap: Long, |
106 |
average_heap: Long, |
|
65893 | 107 |
stored_heap: Long, |
65940 | 108 |
status: Build_Log.Session_Status.Value, |
109 |
errors: List[String]) |
|
65893 | 110 |
{ |
111 |
def finished: Boolean = status == Build_Log.Session_Status.finished |
|
112 |
def failed: Boolean = status == Build_Log.Session_Status.failed |
|
65940 | 113 |
|
114 |
def present_errors(name: String): XML.Body = |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
115 |
{ |
66881 | 116 |
if (errors.isEmpty) |
117 |
HTML.text(name + print_version(isabelle_version, afp_version, chapter)) |
|
65940 | 118 |
else { |
65944 | 119 |
HTML.tooltip_errors(HTML.text(name), errors.map(s => HTML.text(Symbol.decode(s)))) :: |
66881 | 120 |
HTML.text(print_version(isabelle_version, afp_version, chapter)) |
65940 | 121 |
} |
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
122 |
} |
65893 | 123 |
} |
65736 | 124 |
|
65865 | 125 |
sealed case class Image(name: String, width: Int, height: Int) |
126 |
{ |
|
127 |
def path: Path = Path.basic(name) |
|
128 |
} |
|
129 |
||
66881 | 130 |
def print_version( |
131 |
isabelle_version: String, afp_version: String = "", chapter: String = "AFP"): String = |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
132 |
{ |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
133 |
val body = |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
134 |
proper_string(isabelle_version).map("Isabelle/" + _).toList ::: |
66881 | 135 |
(if (chapter == "AFP") proper_string(afp_version).map("AFP/" + _) else None).toList |
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
136 |
if (body.isEmpty) "" else body.mkString(" (", ", ", ")") |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
137 |
} |
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
138 |
|
65736 | 139 |
def read_data(options: Options, |
140 |
progress: Progress = No_Progress, |
|
65785 | 141 |
profiles: List[Profile] = default_profiles, |
65736 | 142 |
only_sessions: Set[String] = Set.empty, |
65854 | 143 |
ml_statistics: Boolean = false, |
65750 | 144 |
verbose: Boolean = false): Data = |
65736 | 145 |
{ |
65754 | 146 |
val date = Date.now() |
65792 | 147 |
var data_hosts = Map.empty[String, Set[String]] |
65799 | 148 |
var data_stretch = Map.empty[String, Double] |
65762 | 149 |
var data_entries = Map.empty[String, Map[String, Session]] |
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
150 |
|
65792 | 151 |
def get_hosts(data_name: String): Set[String] = |
152 |
data_hosts.getOrElse(data_name, Set.empty) |
|
153 |
||
65736 | 154 |
val store = Build_Log.store(options) |
155 |
using(store.open_database())(db => |
|
64089 | 156 |
{ |
65764 | 157 |
for (profile <- profiles.sortBy(_.description)) { |
158 |
progress.echo("input " + quote(profile.description)) |
|
65854 | 159 |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
160 |
val afp = profile.afp |
65736 | 161 |
val columns = |
162 |
List( |
|
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
163 |
Build_Log.Data.pull_date(afp), |
65792 | 164 |
Build_Log.Prop.build_host, |
65796 | 165 |
Build_Log.Prop.isabelle_version, |
166 |
Build_Log.Prop.afp_version, |
|
65752
ed7b5cd3a7f2
more uniform threads value, notably for Pure session;
wenzelm
parents:
65751
diff
changeset
|
167 |
Build_Log.Settings.ISABELLE_BUILD_OPTIONS, |
65736 | 168 |
Build_Log.Settings.ML_PLATFORM, |
169 |
Build_Log.Data.session_name, |
|
66881 | 170 |
Build_Log.Data.chapter, |
65736 | 171 |
Build_Log.Data.threads, |
172 |
Build_Log.Data.timing_elapsed, |
|
173 |
Build_Log.Data.timing_cpu, |
|
174 |
Build_Log.Data.timing_gc, |
|
175 |
Build_Log.Data.ml_timing_elapsed, |
|
176 |
Build_Log.Data.ml_timing_cpu, |
|
65769 | 177 |
Build_Log.Data.ml_timing_gc, |
65893 | 178 |
Build_Log.Data.heap_size, |
65940 | 179 |
Build_Log.Data.status, |
180 |
Build_Log.Data.errors) ::: |
|
65854 | 181 |
(if (ml_statistics) List(Build_Log.Data.ml_statistics) else Nil) |
63700 | 182 |
|
65752
ed7b5cd3a7f2
more uniform threads value, notably for Pure session;
wenzelm
parents:
65751
diff
changeset
|
183 |
val Threads_Option = """threads\s*=\s*(\d+)""".r |
ed7b5cd3a7f2
more uniform threads value, notably for Pure session;
wenzelm
parents:
65751
diff
changeset
|
184 |
|
65799 | 185 |
val sql = profile.select(options, columns, only_sessions) |
65750 | 186 |
if (verbose) progress.echo(sql) |
187 |
||
188 |
db.using_statement(sql)(stmt => |
|
65736 | 189 |
{ |
65740 | 190 |
val res = stmt.execute_query() |
191 |
while (res.next()) { |
|
65766
2edb89630a80
more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents:
65765
diff
changeset
|
192 |
val session_name = res.string(Build_Log.Data.session_name) |
66881 | 193 |
val chapter = res.string(Build_Log.Data.chapter) |
65764 | 194 |
val threads = |
195 |
{ |
|
196 |
val threads1 = |
|
197 |
res.string(Build_Log.Settings.ISABELLE_BUILD_OPTIONS) match { |
|
65895
744878d72021
more general workaround for failed sessions (again, see also 2edb89630a80, ed7b5cd3a7f2);
wenzelm
parents:
65893
diff
changeset
|
198 |
case Threads_Option(Value.Int(i)) => i |
65764 | 199 |
case _ => 1 |
200 |
} |
|
201 |
val threads2 = res.get_int(Build_Log.Data.threads).getOrElse(1) |
|
202 |
threads1 max threads2 |
|
203 |
} |
|
65766
2edb89630a80
more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents:
65765
diff
changeset
|
204 |
val ml_platform = res.string(Build_Log.Settings.ML_PLATFORM) |
65762 | 205 |
val data_name = |
65764 | 206 |
profile.description + |
207 |
(if (ml_platform.startsWith("x86_64")) ", 64bit" else "") + |
|
208 |
(if (threads == 1) "" else ", " + threads + " threads") |
|
63703 | 209 |
|
65799 | 210 |
res.get_string(Build_Log.Prop.build_host).foreach(host => |
211 |
data_hosts += (data_name -> (get_hosts(data_name) + host))) |
|
212 |
||
213 |
data_stretch += (data_name -> profile.stretch(options)) |
|
214 |
||
65854 | 215 |
val isabelle_version = res.string(Build_Log.Prop.isabelle_version) |
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
216 |
val afp_version = res.string(Build_Log.Prop.afp_version) |
65854 | 217 |
|
218 |
val ml_stats = |
|
219 |
ML_Statistics( |
|
220 |
if (ml_statistics) |
|
65857 | 221 |
Properties.uncompress(res.bytes(Build_Log.Data.ml_statistics)) |
66881 | 222 |
else Nil, |
223 |
heading = session_name + print_version(isabelle_version, afp_version, chapter)) |
|
65854 | 224 |
|
65736 | 225 |
val entry = |
65796 | 226 |
Entry( |
66881 | 227 |
chapter = chapter, |
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
228 |
pull_date = res.date(Build_Log.Data.pull_date(afp)), |
65854 | 229 |
isabelle_version = isabelle_version, |
66880
486f4af28db9
more thorough treatment of afp_version and afp_pull_date;
wenzelm
parents:
66254
diff
changeset
|
230 |
afp_version = afp_version, |
65796 | 231 |
timing = |
232 |
res.timing( |
|
233 |
Build_Log.Data.timing_elapsed, |
|
234 |
Build_Log.Data.timing_cpu, |
|
235 |
Build_Log.Data.timing_gc), |
|
236 |
ml_timing = |
|
237 |
res.timing( |
|
238 |
Build_Log.Data.ml_timing_elapsed, |
|
239 |
Build_Log.Data.ml_timing_cpu, |
|
240 |
Build_Log.Data.ml_timing_gc), |
|
65859 | 241 |
maximum_heap = ml_stats.maximum_heap_size, |
242 |
average_heap = ml_stats.average_heap_size, |
|
65893 | 243 |
stored_heap = ML_Statistics.heap_scale(res.long(Build_Log.Data.heap_size)), |
65940 | 244 |
status = Build_Log.Session_Status.withName(res.string(Build_Log.Data.status)), |
245 |
errors = Build_Log.uncompress_errors(res.bytes(Build_Log.Data.errors))) |
|
65736 | 246 |
|
65762 | 247 |
val sessions = data_entries.getOrElse(data_name, Map.empty) |
65766
2edb89630a80
more specific workaround (see also ed7b5cd3a7f2);
wenzelm
parents:
65765
diff
changeset
|
248 |
val entries = sessions.get(session_name).map(_.entries) getOrElse Nil |
65865 | 249 |
val session = Session(session_name, threads, entry :: entries, ml_stats) |
66882 | 250 |
|
251 |
if (!afp || chapter == "AFP") { |
|
252 |
data_entries += (data_name -> (sessions + (session_name -> session))) |
|
253 |
} |
|
65736 | 254 |
} |
255 |
}) |
|
256 |
} |
|
257 |
}) |
|
258 |
||
65792 | 259 |
val sorted_entries = |
65762 | 260 |
(for { |
65792 | 261 |
(name, sessions) <- data_entries.toList |
65847
ad35427dbe88
less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents:
65838
diff
changeset
|
262 |
sorted_sessions <- proper_list(sessions.toList.map(_._2).sortBy(_.order)) |
65799 | 263 |
} |
264 |
yield { |
|
265 |
val hosts = get_hosts(name).toList.sorted |
|
266 |
val stretch = data_stretch(name) |
|
267 |
Data_Entry(name, hosts, stretch, sorted_sessions) |
|
268 |
}).sortBy(_.name) |
|
65792 | 269 |
|
270 |
Data(date, sorted_entries) |
|
65736 | 271 |
} |
272 |
||
273 |
||
274 |
/* present data */ |
|
275 |
||
276 |
def present_data(data: Data, |
|
277 |
progress: Progress = No_Progress, |
|
278 |
target_dir: Path = default_target_dir, |
|
65759 | 279 |
image_size: (Int, Int) = default_image_size) |
65736 | 280 |
{ |
65791 | 281 |
def clean_name(name: String): String = |
282 |
name.flatMap(c => if (c == ' ' || c == '/') "_" else if (c == ',') "" else c.toString) |
|
283 |
||
65860 | 284 |
def print_heap(x: Long): Option[String] = |
65866 | 285 |
if (x == 0L) None else Some(x.toString + " M") |
65854 | 286 |
|
65838 | 287 |
HTML.write_document(target_dir, "index.html", |
65945 | 288 |
List(HTML.title("Isabelle build status")), |
65838 | 289 |
List(HTML.chapter("Isabelle build status"), |
290 |
HTML.par( |
|
291 |
List(HTML.description( |
|
292 |
List(HTML.text("status date:") -> HTML.text(data.date.toString))))), |
|
293 |
HTML.par( |
|
294 |
List(HTML.itemize(data.entries.map({ case data_entry => |
|
65893 | 295 |
List( |
296 |
HTML.link(clean_name(data_entry.name) + "/index.html", |
|
297 |
HTML.text(data_entry.name))) ::: |
|
298 |
(data_entry.failed_sessions match { |
|
299 |
case Nil => Nil |
|
300 |
case sessions => |
|
65940 | 301 |
HTML.break ::: |
65992 | 302 |
List(HTML.span(HTML.error_message, HTML.text("Failed sessions:"))) ::: |
65940 | 303 |
List(HTML.itemize(sessions.map(s => s.head.present_errors(s.name)))) |
65893 | 304 |
}) |
305 |
})))))) |
|
65786 | 306 |
|
65792 | 307 |
for (data_entry <- data.entries) { |
308 |
val data_name = data_entry.name |
|
309 |
||
65865 | 310 |
val (image_width, image_height) = image_size |
311 |
val image_width_stretch = (image_width * data_entry.stretch).toInt |
|
65799 | 312 |
|
65786 | 313 |
progress.echo("output " + quote(data_name)) |
314 |
||
65764 | 315 |
val dir = target_dir + Path.basic(clean_name(data_name)) |
65736 | 316 |
Isabelle_System.mkdirs(dir) |
317 |
||
65764 | 318 |
val session_plots = |
319 |
Par_List.map((session: Session) => |
|
320 |
Isabelle_System.with_tmp_file(session.name, "data") { data_file => |
|
321 |
Isabelle_System.with_tmp_file(session.name, "gnuplot") { gnuplot_file => |
|
63706 | 322 |
|
65865 | 323 |
def plot_name(kind: String): String = session.name + "_" + kind + ".png" |
324 |
||
65764 | 325 |
File.write(data_file, |
326 |
cat_lines( |
|
65893 | 327 |
session.finished_entries.map(entry => |
65854 | 328 |
List(entry.pull_date.unix_epoch, |
65764 | 329 |
entry.timing.elapsed.minutes, |
330 |
entry.timing.resources.minutes, |
|
331 |
entry.ml_timing.elapsed.minutes, |
|
65769 | 332 |
entry.ml_timing.resources.minutes, |
65866 | 333 |
entry.maximum_heap, |
334 |
entry.average_heap, |
|
335 |
entry.stored_heap).mkString(" ")))) |
|
65736 | 336 |
|
65764 | 337 |
val max_time = |
65893 | 338 |
((0.0 /: session.finished_entries){ case (m, entry) => |
65764 | 339 |
m.max(entry.timing.elapsed.minutes). |
340 |
max(entry.timing.resources.minutes). |
|
341 |
max(entry.ml_timing.elapsed.minutes). |
|
342 |
max(entry.ml_timing.resources.minutes) } max 0.1) * 1.1 |
|
65769 | 343 |
val timing_range = "[0:" + max_time + "]" |
65763 | 344 |
|
65865 | 345 |
def gnuplot(plot_name: String, plots: List[String], range: String): Image = |
65764 | 346 |
{ |
65865 | 347 |
val image = Image(plot_name, image_width_stretch, image_height) |
65764 | 348 |
|
349 |
File.write(gnuplot_file, """ |
|
65865 | 350 |
set terminal png size """ + image.width + "," + image.height + """ |
351 |
set output """ + quote(File.standard_path(dir + image.path)) + """ |
|
65759 | 352 |
set xdata time |
353 |
set timefmt "%s" |
|
354 |
set format x "%d-%b" |
|
65762 | 355 |
set xlabel """ + quote(session.name) + """ noenhanced |
65763 | 356 |
set key left bottom |
65769 | 357 |
plot [] """ + range + " " + |
358 |
plots.map(s => quote(data_file.implode) + " " + s).mkString(", ") + "\n") |
|
65759 | 359 |
|
65764 | 360 |
val result = |
361 |
Isabelle_System.bash("\"$ISABELLE_GNUPLOT\" " + File.bash_path(gnuplot_file)) |
|
362 |
if (!result.ok) |
|
363 |
result.error("Gnuplot failed for " + data_name + "/" + plot_name).check |
|
364 |
||
65865 | 365 |
image |
65764 | 366 |
} |
65759 | 367 |
|
65765 | 368 |
val timing_plots = |
65769 | 369 |
{ |
370 |
val plots1 = |
|
371 |
List( |
|
372 |
""" using 1:2 smooth sbezier title "elapsed time (smooth)" """, |
|
373 |
""" using 1:2 smooth csplines title "elapsed time" """) |
|
374 |
val plots2 = |
|
375 |
List( |
|
376 |
""" using 1:3 smooth sbezier title "cpu time (smooth)" """, |
|
377 |
""" using 1:3 smooth csplines title "cpu time" """) |
|
378 |
if (session.threads == 1) plots1 else plots1 ::: plots2 |
|
379 |
} |
|
65765 | 380 |
|
65764 | 381 |
val ml_timing_plots = |
382 |
List( |
|
65765 | 383 |
""" using 1:4 smooth sbezier title "ML elapsed time (smooth)" """, |
384 |
""" using 1:4 smooth csplines title "ML elapsed time" """, |
|
65764 | 385 |
""" using 1:5 smooth sbezier title "ML cpu time (smooth)" """, |
65765 | 386 |
""" using 1:5 smooth csplines title "ML cpu time" """) |
65736 | 387 |
|
65769 | 388 |
val heap_plots = |
389 |
List( |
|
65859 | 390 |
""" using 1:6 smooth sbezier title "maximum heap (smooth)" """, |
391 |
""" using 1:6 smooth csplines title "maximum heap" """, |
|
392 |
""" using 1:7 smooth sbezier title "average heap (smooth)" """, |
|
393 |
""" using 1:7 smooth csplines title "average heap" """, |
|
65868 | 394 |
""" using 1:8 smooth sbezier title "stored heap (smooth)" """, |
395 |
""" using 1:8 smooth csplines title "stored heap" """) |
|
65769 | 396 |
|
65865 | 397 |
def jfreechart(plot_name: String, fields: ML_Statistics.Fields): Image = |
398 |
{ |
|
399 |
val image = Image(plot_name, image_width, image_height) |
|
400 |
val chart = |
|
401 |
session.ml_statistics.chart( |
|
402 |
fields._1 + ": " + session.ml_statistics.heading, fields._2) |
|
403 |
Graphics_File.write_chart_png( |
|
404 |
(dir + image.path).file, chart, image.width, image.height) |
|
405 |
image |
|
406 |
} |
|
407 |
||
408 |
val images = |
|
65847
ad35427dbe88
less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents:
65838
diff
changeset
|
409 |
(if (session.check_timing) |
ad35427dbe88
less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents:
65838
diff
changeset
|
410 |
List( |
65865 | 411 |
gnuplot(plot_name("timing"), timing_plots, timing_range), |
412 |
gnuplot(plot_name("ml_timing"), ml_timing_plots, timing_range)) |
|
413 |
else Nil) ::: |
|
414 |
(if (session.check_heap) |
|
415 |
List(gnuplot(plot_name("heap"), heap_plots, "[0:]")) |
|
65847
ad35427dbe88
less restrictive filter: omit empty charts, but show latest timing;
wenzelm
parents:
65838
diff
changeset
|
416 |
else Nil) ::: |
65865 | 417 |
(if (session.ml_statistics.content.nonEmpty) |
418 |
List(jfreechart(plot_name("heap_chart"), ML_Statistics.heap_fields)) ::: |
|
419 |
(if (session.threads > 1) |
|
65867 | 420 |
List( |
421 |
jfreechart(plot_name("tasks_chart"), ML_Statistics.tasks_fields), |
|
422 |
jfreechart(plot_name("workers_chart"), ML_Statistics.workers_fields)) |
|
65865 | 423 |
else Nil) |
424 |
else Nil) |
|
65769 | 425 |
|
65865 | 426 |
session.name -> images |
65764 | 427 |
} |
65792 | 428 |
}, data_entry.sessions).toMap |
65754 | 429 |
|
65838 | 430 |
HTML.write_document(dir, "index.html", |
431 |
List(HTML.title("Isabelle build status for " + data_name)), |
|
432 |
HTML.chapter("Isabelle build status for " + data_name) :: |
|
433 |
HTML.par( |
|
434 |
List(HTML.description( |
|
65754 | 435 |
List( |
65838 | 436 |
HTML.text("status date:") -> HTML.text(data.date.toString), |
437 |
HTML.text("build host:") -> HTML.text(commas(data_entry.hosts)))))) :: |
|
438 |
HTML.par( |
|
439 |
List(HTML.itemize( |
|
440 |
data_entry.sessions.map(session => |
|
441 |
HTML.link("#session_" + session.name, HTML.text(session.name)) :: |
|
65863 | 442 |
HTML.text(" (" + session.head.timing.message_resources + ")"))))) :: |
65838 | 443 |
data_entry.sessions.flatMap(session => |
444 |
List( |
|
65992 | 445 |
HTML.section(HTML.id("session_" + session.name), session.name), |
65838 | 446 |
HTML.par( |
447 |
HTML.description( |
|
448 |
List( |
|
65863 | 449 |
HTML.text("timing:") -> HTML.text(session.head.timing.message_resources), |
450 |
HTML.text("ML timing:") -> HTML.text(session.head.ml_timing.message_resources)) ::: |
|
451 |
print_heap(session.head.maximum_heap).map(s => |
|
65860 | 452 |
HTML.text("maximum heap:") -> HTML.text(s)).toList ::: |
65863 | 453 |
print_heap(session.head.average_heap).map(s => |
65860 | 454 |
HTML.text("average heap:") -> HTML.text(s)).toList ::: |
65866 | 455 |
print_heap(session.head.stored_heap).map(s => |
456 |
HTML.text("stored heap:") -> HTML.text(s)).toList ::: |
|
65863 | 457 |
proper_string(session.head.isabelle_version).map(s => |
65838 | 458 |
HTML.text("Isabelle version:") -> HTML.text(s)).toList ::: |
65863 | 459 |
proper_string(session.head.afp_version).map(s => |
65838 | 460 |
HTML.text("AFP version:") -> HTML.text(s)).toList) :: |
65865 | 461 |
session_plots.getOrElse(session.name, Nil).map(image => |
65946 | 462 |
HTML.size(image.width / 2, image.height / 2)(HTML.image(image.name))))))) |
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
463 |
} |
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
464 |
} |
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
465 |
|
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
466 |
|
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
467 |
/* Isabelle tool wrapper */ |
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
468 |
|
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
469 |
val isabelle_tool = |
65743 | 470 |
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
|
471 |
{ |
65736 | 472 |
var target_dir = default_target_dir |
65854 | 473 |
var ml_statistics = false |
65736 | 474 |
var only_sessions = Set.empty[String] |
475 |
var options = Options.init() |
|
476 |
var image_size = default_image_size |
|
65750 | 477 |
var verbose = false |
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
478 |
|
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
479 |
val getopts = Getopts(""" |
65743 | 480 |
Usage: isabelle build_status [OPTIONS] |
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
481 |
|
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
482 |
Options are: |
65737 | 483 |
-D DIR target directory (default """ + default_target_dir + """) |
65854 | 484 |
-M include full ML statistics |
63700 | 485 |
-S SESSIONS only given SESSIONS (comma separated) |
65736 | 486 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
65737 | 487 |
-s WxH size of PNG image (default """ + image_size._1 + "x" + image_size._2 + """) |
65750 | 488 |
-v verbose |
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
489 |
|
65736 | 490 |
Present performance statistics from build log database, which is specified |
65782 | 491 |
via system options build_log_database_host, build_log_database_user, |
492 |
build_log_history etc. |
|
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
493 |
""", |
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
494 |
"D:" -> (arg => target_dir = Path.explode(arg)), |
65854 | 495 |
"M" -> (_ => ml_statistics = true), |
63700 | 496 |
"S:" -> (arg => only_sessions = space_explode(',', arg).toSet), |
65736 | 497 |
"o:" -> (arg => options = options + arg), |
63700 | 498 |
"s:" -> (arg => |
63805 | 499 |
space_explode('x', arg).map(Value.Int.parse(_)) match { |
65736 | 500 |
case List(w, h) if w > 0 && h > 0 => image_size = (w, h) |
63700 | 501 |
case _ => error("Error bad PNG image size: " + quote(arg)) |
65750 | 502 |
}), |
503 |
"v" -> (_ => verbose = true)) |
|
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
504 |
|
65736 | 505 |
val more_args = getopts(args) |
506 |
if (more_args.nonEmpty) getopts.usage() |
|
63700 | 507 |
|
65736 | 508 |
val progress = new Console_Progress |
63688
cc57255bf6ae
gnuplot presentation similar to former isatest-statistics;
wenzelm
parents:
63686
diff
changeset
|
509 |
|
65785 | 510 |
build_status(options, progress = progress, only_sessions = only_sessions, verbose = verbose, |
65854 | 511 |
target_dir = target_dir, ml_statistics = ml_statistics, image_size = image_size) |
65736 | 512 |
|
64161 | 513 |
}, admin = true) |
63686 | 514 |
} |