77238
|
1 |
/* Title: Pure/Tools/build_process.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Build process for sessions, with build database, optional heap, and
|
|
5 |
optional presentation.
|
|
6 |
*/
|
|
7 |
|
|
8 |
package isabelle
|
|
9 |
|
|
10 |
|
|
11 |
object Build_Process {
|
|
12 |
/* timings from session database */
|
|
13 |
|
77239
|
14 |
object Session_Timing {
|
|
15 |
def empty(session: String): Session_Timing = new Session_Timing(session, Time.zero, Nil)
|
77238
|
16 |
|
77239
|
17 |
def load(
|
|
18 |
session: String,
|
|
19 |
store: Sessions.Store,
|
|
20 |
progress: Progress = new Progress
|
|
21 |
): Session_Timing = {
|
|
22 |
store.try_open_database(session) match {
|
|
23 |
case None => empty(session)
|
77238
|
24 |
case Some(db) =>
|
|
25 |
def ignore_error(msg: String) = {
|
|
26 |
progress.echo_warning("Ignoring bad database " + db +
|
77239
|
27 |
" for session " + quote(session) + (if (msg == "") "" else ":\n" + msg))
|
|
28 |
empty(session)
|
77238
|
29 |
}
|
|
30 |
try {
|
77239
|
31 |
val command_timings = store.read_command_timings(db, session)
|
|
32 |
val elapsed =
|
|
33 |
store.read_session_timing(db, session) match {
|
|
34 |
case Markup.Elapsed(s) => Time.seconds(s)
|
|
35 |
case _ => Time.zero
|
77238
|
36 |
}
|
77239
|
37 |
new Session_Timing(session, elapsed, command_timings)
|
77238
|
38 |
}
|
|
39 |
catch {
|
|
40 |
case ERROR(msg) => ignore_error(msg)
|
|
41 |
case exn: java.lang.Error => ignore_error(Exn.message(exn))
|
|
42 |
case _: XML.Error => ignore_error("XML.Error")
|
|
43 |
}
|
|
44 |
finally { db.close() }
|
|
45 |
}
|
|
46 |
}
|
|
47 |
}
|
77239
|
48 |
|
|
49 |
final class Session_Timing(
|
|
50 |
val session: String,
|
|
51 |
val elapsed: Time,
|
|
52 |
val command_timings: List[Properties.T]
|
|
53 |
) {
|
|
54 |
override def toString: String =
|
|
55 |
session + (if (elapsed.is_relevant) " (" + elapsed.message_hms + " elapsed time)" else "")
|
|
56 |
}
|
77238
|
57 |
}
|