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