src/Pure/Tools/profiling.scala
changeset 79095 3bdd3cf5f5e0
parent 78958 c125f75a5144
child 79616 12bb31d01510
equal deleted inserted replaced
79094:58bb68b9470f 79095:3bdd3cf5f5e0
    37     global_thms: Int = 0,
    37     global_thms: Int = 0,
    38     sizeof_thys_id: Space = Space.zero,
    38     sizeof_thys_id: Space = Space.zero,
    39     sizeof_thms_id: Space = Space.zero,
    39     sizeof_thms_id: Space = Space.zero,
    40     sizeof_terms: Space = Space.zero,
    40     sizeof_terms: Space = Space.zero,
    41     sizeof_types: Space = Space.zero,
    41     sizeof_types: Space = Space.zero,
       
    42     sizeof_names: Space = Space.zero,
    42     sizeof_spaces: Space = Space.zero)
    43     sizeof_spaces: Space = Space.zero)
    43 
    44 
    44   object Statistics {
    45   object Statistics {
    45     private val encode_args: XML.Encode.T[List[String]] =
    46     private val encode_args: XML.Encode.T[List[String]] =
    46       (args: List[String]) =>
    47       (args: List[String]) =>
    47         { import XML.Encode._; list(string)(args) }
    48         { import XML.Encode._; list(string)(args) }
    48 
    49 
    49     private val decode_result: XML.Decode.T[Session_Statistics] =
    50     private val decode_result: XML.Decode.T[Session_Statistics] =
    50       (body: XML.Body) =>
    51       (body: XML.Body) =>
    51         {
    52         {
    52           val (a, (b, (c, (d, (e, (f, (g, (h, (i, j))))))))) = {
    53           val (a, (b, (c, (d, (e, (f, (g, (h, (i, (j, k)))))))))) = {
    53             import XML.Decode._
    54             import XML.Decode._
    54             pair(int, pair(int, pair(int, pair(int, pair(int,
    55             pair(int, pair(int, pair(int, pair(int, pair(int,
    55               pair(long, pair(long, pair(long, pair(long, long)))))))))(body)
    56               pair(long, pair(long, pair(long, pair(long, pair(long, long))))))))))(body)
    56           }
    57           }
    57           Session_Statistics(
    58           Session_Statistics(
    58             theories = a,
    59             theories = a,
    59             garbage_theories = b,
    60             garbage_theories = b,
    60             locales = c,
    61             locales = c,
    62             global_thms = e,
    63             global_thms = e,
    63             sizeof_thys_id = Space.bytes(f),
    64             sizeof_thys_id = Space.bytes(f),
    64             sizeof_thms_id = Space.bytes(g),
    65             sizeof_thms_id = Space.bytes(g),
    65             sizeof_terms = Space.bytes(h),
    66             sizeof_terms = Space.bytes(h),
    66             sizeof_types = Space.bytes(i),
    67             sizeof_types = Space.bytes(i),
    67             sizeof_spaces = Space.bytes(j))
    68             sizeof_names = Space.bytes(j),
       
    69             sizeof_spaces = Space.bytes(k))
    68         }
    70         }
    69 
    71 
    70     def make(
    72     def make(
    71       store: Store,
    73       store: Store,
    72       session_background: Sessions.Background,
    74       session_background: Sessions.Background,
   100         heap_size = File.space(store.the_heap(session_name)),
   102         heap_size = File.space(store.the_heap(session_name)),
   101         thys_id_size = session.sizeof_thys_id,
   103         thys_id_size = session.sizeof_thys_id,
   102         thms_id_size = session.sizeof_thms_id,
   104         thms_id_size = session.sizeof_thms_id,
   103         terms_size = session.sizeof_terms,
   105         terms_size = session.sizeof_terms,
   104         types_size = session.sizeof_types,
   106         types_size = session.sizeof_types,
       
   107         names_size = session.sizeof_names,
   105         spaces_size = session.sizeof_spaces)
   108         spaces_size = session.sizeof_spaces)
   106     }
   109     }
   107 
   110 
   108     val empty: Statistics = new Statistics()
   111     val empty: Statistics = new Statistics()
   109 
   112 
   119         "heap_size",
   122         "heap_size",
   120         "thys_id_size%",
   123         "thys_id_size%",
   121         "thms_id_size%",
   124         "thms_id_size%",
   122         "terms_size%",
   125         "terms_size%",
   123         "types_size%",
   126         "types_size%",
       
   127         "names_size%",
   124         "spaces_size%")
   128         "spaces_size%")
   125 
   129 
   126     def header: List[String] =
   130     def header: List[String] =
   127       "session" :: header0.flatMap(a => List(a, "\u2211" + a))
   131       "session" :: header0.flatMap(a => List(a, "\u2211" + a))
   128   }
   132   }
   138     val heap_size: Space = Space.zero,
   142     val heap_size: Space = Space.zero,
   139     val thys_id_size: Space = Space.zero,
   143     val thys_id_size: Space = Space.zero,
   140     val thms_id_size: Space = Space.zero,
   144     val thms_id_size: Space = Space.zero,
   141     val terms_size: Space = Space.zero,
   145     val terms_size: Space = Space.zero,
   142     val types_size: Space = Space.zero,
   146     val types_size: Space = Space.zero,
       
   147     val names_size: Space = Space.zero,
   143     val spaces_size: Space = Space.zero
   148     val spaces_size: Space = Space.zero
   144   ) {
   149   ) {
   145     private def print_total_theories: String =
   150     private def print_total_theories: String =
   146       if (theories == 0) "0"
   151       if (theories == 0) "0"
   147       else {
   152       else {
   167         heap_size.print,
   172         heap_size.print,
   168         size_percentage(thys_id_size).toString,
   173         size_percentage(thys_id_size).toString,
   169         size_percentage(thms_id_size).toString,
   174         size_percentage(thms_id_size).toString,
   170         size_percentage(terms_size).toString,
   175         size_percentage(terms_size).toString,
   171         size_percentage(types_size).toString,
   176         size_percentage(types_size).toString,
       
   177         size_percentage(names_size).toString,
   172         size_percentage(spaces_size).toString)
   178         size_percentage(spaces_size).toString)
   173 
   179 
   174     def fields: List[Any] =
   180     def fields: List[Any] =
   175       session :: fields0.zipWithIndex.flatMap({ case (a, i) => List(a, cumulative.fields0(i)) })
   181       session :: fields0.zipWithIndex.flatMap({ case (a, i) => List(a, cumulative.fields0(i)) })
   176 
   182 
   188             heap_size = other.cumulative.heap_size + heap_size,
   194             heap_size = other.cumulative.heap_size + heap_size,
   189             thys_id_size = other.cumulative.thys_id_size + thys_id_size,
   195             thys_id_size = other.cumulative.thys_id_size + thys_id_size,
   190             thms_id_size = other.cumulative.thms_id_size + thms_id_size,
   196             thms_id_size = other.cumulative.thms_id_size + thms_id_size,
   191             terms_size = other.cumulative.terms_size + terms_size,
   197             terms_size = other.cumulative.terms_size + terms_size,
   192             types_size = other.cumulative.types_size + types_size,
   198             types_size = other.cumulative.types_size + types_size,
       
   199             names_size = other.cumulative.names_size + names_size,
   193             spaces_size = other.cumulative.spaces_size + spaces_size)
   200             spaces_size = other.cumulative.spaces_size + spaces_size)
   194       }
   201       }
   195 
   202 
   196     override def toString: String = "Statistics(" + session + ")"
   203     override def toString: String = "Statistics(" + session + ")"
   197   }
   204   }