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