src/Pure/ML/ml_statistics.ML
author wenzelm
Wed, 25 Jan 2017 23:08:29 +0100
changeset 64948 e655d965307c
parent 63806 c54a53ef1873
child 69822 8c587dd44f51
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62459
7a5d88dd8cc9 support only polyml-5.3.0 and polyml-5.6;
wenzelm
parents: 51990
diff changeset
     1
(*  Title:      Pure/ML/ml_statistics.ML
50255
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     3
62945
c38c08889aa9 tuned comments;
wenzelm
parents: 62459
diff changeset
     4
ML runtime statistics.
50255
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     5
*)
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     6
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     7
signature ML_STATISTICS =
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     8
sig
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
     9
  val get: unit -> Properties.T
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    10
end;
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    11
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    12
structure ML_Statistics: ML_STATISTICS =
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    13
struct
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    14
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    15
fun get () =
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    16
  let
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    17
    val
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    18
     {gcFullGCs,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    19
      gcPartialGCs,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    20
      sizeAllocation,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    21
      sizeAllocationFree,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    22
      sizeHeap,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    23
      sizeHeapFreeLastFullGC,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    24
      sizeHeapFreeLastGC,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    25
      threadsInML,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    26
      threadsTotal,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    27
      threadsWaitCondVar,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    28
      threadsWaitIO,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    29
      threadsWaitMutex,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    30
      threadsWaitSignal,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    31
      timeGCSystem,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    32
      timeGCUser,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    33
      timeNonGCSystem,
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    34
      timeNonGCUser,
50656
561d79d7031f include user counters as well;
wenzelm
parents: 50280
diff changeset
    35
      userCounters} = PolyML.Statistics.getLocalStats ();
561d79d7031f include user counters as well;
wenzelm
parents: 50280
diff changeset
    36
    val user_counters =
561d79d7031f include user counters as well;
wenzelm
parents: 50280
diff changeset
    37
      Vector.foldri
63806
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    38
        (fn (i, j, res) => ("user_counter" ^ Value.print_int i, Value.print_int j) :: res)
50656
561d79d7031f include user counters as well;
wenzelm
parents: 50280
diff changeset
    39
        [] userCounters;
50255
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    40
  in
63806
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    41
    [("full_GCs", Value.print_int gcFullGCs),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    42
     ("partial_GCs", Value.print_int gcPartialGCs),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    43
     ("size_allocation", Value.print_int sizeAllocation),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    44
     ("size_allocation_free", Value.print_int sizeAllocationFree),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    45
     ("size_heap", Value.print_int sizeHeap),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    46
     ("size_heap_free_last_full_GC", Value.print_int sizeHeapFreeLastFullGC),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    47
     ("size_heap_free_last_GC", Value.print_int sizeHeapFreeLastGC),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    48
     ("threads_in_ML", Value.print_int threadsInML),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    49
     ("threads_total", Value.print_int threadsTotal),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    50
     ("threads_wait_condvar", Value.print_int threadsWaitCondVar),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    51
     ("threads_wait_IO", Value.print_int threadsWaitIO),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    52
     ("threads_wait_mutex", Value.print_int threadsWaitMutex),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    53
     ("threads_wait_signal", Value.print_int threadsWaitSignal),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    54
     ("time_CPU", Value.print_real (Time.toReal timeNonGCSystem + Time.toReal timeNonGCUser)),
c54a53ef1873 clarified modules;
wenzelm
parents: 62945
diff changeset
    55
     ("time_GC", Value.print_real (Time.toReal timeGCSystem + Time.toReal timeGCUser))] @
50656
561d79d7031f include user counters as well;
wenzelm
parents: 50280
diff changeset
    56
    user_counters
50255
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    57
  end;
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    58
d0ec1f0d1d7d some support for ML runtime statistics;
wenzelm
parents:
diff changeset
    59
end;