src/Tools/Profiling.thy
author desharna
Thu, 02 Oct 2025 11:02:15 +0000
changeset 83240 dfa14d921fd2
parent 82979 98faa43a2505
permissions -rw-r--r--
consider nat as a datatype in the SMT-LIB module
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
82978
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
     1
(*  Title:      Tools/profiling.thy
78315
addecc8de2c4 proper system integration and renaming;
wenzelm
parents: 78314
diff changeset
     2
    Author:     Makarius
78314
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
     3
78315
addecc8de2c4 proper system integration and renaming;
wenzelm
parents: 78314
diff changeset
     4
Session profiling based on loaded ML image.
78314
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
     5
*)
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
     6
78315
addecc8de2c4 proper system integration and renaming;
wenzelm
parents: 78314
diff changeset
     7
theory Profiling
78314
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
     8
  imports Pure
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
     9
begin
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
    10
82978
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    11
ML \<open>
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    12
signature PROFILING =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    13
sig
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    14
  val locales: theory -> string list
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    15
  val locale_thms: theory -> string -> thm list
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    16
  val locales_thms: theory -> thm list
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    17
  val global_thms: theory -> thm list
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    18
  val all_thms: theory -> thm list
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    19
  type session_statistics =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    20
   {theories: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    21
    garbage_theories: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    22
    locales: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    23
    locale_thms: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    24
    global_thms: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    25
    sizeof_thys_id: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    26
    sizeof_thms_id: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    27
    sizeof_terms: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    28
    sizeof_types: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    29
    sizeof_names: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    30
    sizeof_spaces: int}
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    31
  val session_statistics: string list -> session_statistics
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    32
  val main: unit -> unit
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    33
end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    34
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    35
structure Profiling: PROFILING =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    36
struct
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    37
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    38
(* theory content *)
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    39
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    40
fun locales thy =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    41
  let
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    42
    val parent_spaces = map Locale.locale_space (Theory.parents_of thy);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    43
    fun add name =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    44
      if exists (fn space => Name_Space.declared space name) parent_spaces then I
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    45
      else cons name;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    46
  in fold add (Locale.get_locales thy) [] end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    47
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    48
fun proper_thm thm = not (Thm.eq_thm_prop (Drule.dummy_thm, thm));
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    49
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    50
fun locale_thms thy loc =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    51
  (Locale.locale_notes thy loc, []) |->
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    52
    (fold (#2 #> fold (#2 #> (fold (#1 #> fold (fn thm => proper_thm thm ? cons thm ))))));
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    53
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    54
fun locales_thms thy =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    55
  maps (locale_thms thy) (locales thy);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    56
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    57
fun global_thms thy =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    58
  Facts.dest_static true
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    59
    (map Global_Theory.facts_of (Theory.parents_of thy)) (Global_Theory.facts_of thy)
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    60
  |> maps #2;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    61
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    62
fun all_thms thy = locales_thms thy @ global_thms thy;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    63
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    64
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    65
(* session content *)
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    66
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    67
fun session_content thys =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    68
  let
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    69
    val thms = maps all_thms thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    70
    val thys_id = map Context.theory_id thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    71
    val thms_id = map Thm.theory_id thms;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    72
    val terms =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    73
      Termset.dest ((fold o Thm.fold_terms {hyps = true}) Termset.insert thms Termset.empty);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    74
    val types = Typset.dest ((fold o fold_types) Typset.insert terms Typset.empty);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    75
    val spaces =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    76
      maps (fn f => map f thys)
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    77
       [Sign.class_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    78
        Sign.type_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    79
        Sign.const_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    80
        Theory.axiom_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    81
        Thm.oracle_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    82
        Global_Theory.fact_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    83
        Locale.locale_space,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    84
        Attrib.attribute_space o Context.Theory,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    85
        Method.method_space o Context.Theory];
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    86
     val names = Symset.dest (Symset.merges (map (Symset.make o Name_Space.get_names) spaces));
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    87
  in
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    88
    {thys_id = thys_id, thms_id = thms_id, terms = terms,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    89
      types = types, names = names, spaces = spaces}
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    90
  end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    91
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    92
fun sizeof1_diff (a, b) = ML_Heap.sizeof1 a - ML_Heap.sizeof1 b;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    93
fun sizeof_list_diff (a, b) = ML_Heap.sizeof_list a - ML_Heap.sizeof_list b;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    94
fun sizeof_diff (a, b) = ML_Heap.sizeof a - ML_Heap.sizeof b;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    95
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    96
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    97
(* session statistics *)
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    98
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
    99
type session_statistics =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   100
 {theories: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   101
  garbage_theories: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   102
  locales: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   103
  locale_thms: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   104
  global_thms: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   105
  sizeof_thys_id: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   106
  sizeof_thms_id: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   107
  sizeof_terms: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   108
  sizeof_types: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   109
  sizeof_names: int,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   110
  sizeof_spaces: int};
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   111
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   112
fun session_statistics theories : session_statistics =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   113
  let
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   114
    val theories_member = Symtab.defined (Symtab.make_set theories) o Context.theory_long_name;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   115
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   116
    val context_thys =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   117
      #contexts (Context.finish_tracing ())
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   118
      |> map_filter (fn (Context.Theory thy, _) => SOME thy | _ => NONE);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   119
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   120
    val loader_thys = map Thy_Info.get_theory (Thy_Info.get_names ());
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   121
    val loaded_thys = filter theories_member loader_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   122
    val loaded_context_thys = filter theories_member context_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   123
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   124
    val all_thys = loader_thys @ context_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   125
    val base_thys = filter_out theories_member all_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   126
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   127
    val {thys_id = all_thys_id, thms_id = all_thms_id, terms = all_terms,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   128
          types = all_types, names = all_names, spaces = all_spaces} = session_content all_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   129
    val {thys_id = base_thys_id, thms_id = base_thms_id, terms = base_terms,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   130
          types = base_types, names = base_names, spaces = base_spaces} = session_content base_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   131
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   132
    val n = length loaded_thys;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   133
    val m = (case length loaded_context_thys of 0 => 0 | l => l - n);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   134
  in
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   135
    {theories = n,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   136
     garbage_theories = m,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   137
     locales = Integer.sum (map (length o locales) loaded_thys),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   138
     locale_thms = Integer.sum (map (length o locales_thms) loaded_thys),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   139
     global_thms = Integer.sum (map (length o global_thms) loaded_thys),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   140
     sizeof_thys_id =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   141
      sizeof1_diff ((all_thys_id, all_thms_id), (base_thys_id, all_thms_id)) -
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   142
        sizeof_list_diff (all_thys_id, base_thys_id),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   143
     sizeof_thms_id =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   144
      sizeof1_diff ((all_thms_id, all_thys_id), (base_thms_id, all_thys_id)) -
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   145
        sizeof_list_diff (all_thms_id, base_thms_id),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   146
     sizeof_terms =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   147
      sizeof1_diff ((all_terms, all_types, all_names), (base_terms, all_types, all_names)) -
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   148
        sizeof_list_diff (all_terms, base_terms),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   149
     sizeof_types =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   150
      sizeof1_diff ((all_types, all_names), (base_types, all_names)) -
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   151
        sizeof_list_diff (all_types, base_types),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   152
     sizeof_spaces =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   153
      sizeof1_diff ((all_spaces, all_names), (base_spaces, all_names)) -
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   154
        sizeof_list_diff (all_spaces, base_spaces),
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   155
     sizeof_names = sizeof_diff (all_names, base_names)}
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   156
  end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   157
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   158
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   159
(* main entry point for external process *)
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   160
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   161
local
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   162
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   163
val decode_args : string list XML.Decode.T =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   164
  let open XML.Decode in list string end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   165
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   166
val encode_result : session_statistics XML.Encode.T =
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   167
  (fn {theories = a,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   168
       garbage_theories = b,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   169
       locales = c,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   170
       locale_thms = d,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   171
       global_thms = e,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   172
       sizeof_thys_id = f,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   173
       sizeof_thms_id = g,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   174
       sizeof_terms = h,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   175
       sizeof_types = i,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   176
       sizeof_names = j,
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   177
       sizeof_spaces = k} => ((a, (b, (c, (d, (e, (f, (g, (h, (i, (j, k)))))))))))) #>
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   178
  let open XML.Encode in
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   179
    pair int (pair int (pair int (pair int (pair int (pair int (pair int
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   180
      (pair int (pair int (pair int int)))))))))
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   181
  end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   182
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   183
in
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   184
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   185
fun main () =
82979
98faa43a2505 prefer system options, which are easier to change on the spot;
wenzelm
parents: 82978
diff changeset
   186
  (case Options.default_string \<^system_option>\<open>profiling_dir\<close> of
82978
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   187
    "" => ()
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   188
  | dir_name =>
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   189
      let
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   190
        val dir = Path.explode dir_name;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   191
        val args = decode_args (YXML.parse_body (File.read (dir + \<^path>\<open>args.yxml\<close>)));
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   192
        val result = session_statistics args;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   193
      in File.write (dir + \<^path>\<open>result.yxml\<close>) (YXML.string_of_body (encode_result result)) end);
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   194
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   195
end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   196
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   197
end;
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   198
\<close>
85c982ddc82d prefer compact theory + ML module;
wenzelm
parents: 78315
diff changeset
   199
78315
addecc8de2c4 proper system integration and renaming;
wenzelm
parents: 78314
diff changeset
   200
ML_command \<open>Profiling.main ()\<close>
78314
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
   201
1588bec693c2 copy/rename files from private autocorres version e45b9b680d3e;
wenzelm
parents:
diff changeset
   202
end