src/Pure/ML/ml_statistics_polyml-5.5.0.ML
author wenzelm
Fri, 15 Mar 2013 13:46:37 +0100
changeset 51432 903be59d9665
parent 50738 d5725e56cd04
child 51990 cc66addbba6d
permissions -rw-r--r--
simplified time_CPU and time_GC; derive relative speed from time (considered as step function);

(*  Title:      Pure/ML/ml_statistics_polyml-5.5.0.ML
    Author:     Makarius

ML runtime statistics for Poly/ML 5.5.0.
*)

signature ML_STATISTICS =
sig
  val get: unit -> Properties.T
end;

structure ML_Statistics: ML_STATISTICS =
struct

fun get () =
  let
    val
     {gcFullGCs,
      gcPartialGCs,
      sizeAllocation,
      sizeAllocationFree,
      sizeHeap,
      sizeHeapFreeLastFullGC,
      sizeHeapFreeLastGC,
      threadsInML,
      threadsTotal,
      threadsWaitCondVar,
      threadsWaitIO,
      threadsWaitMutex,
      threadsWaitSignal,
      timeGCSystem,
      timeGCUser,
      timeNonGCSystem,
      timeNonGCUser,
      userCounters} = PolyML.Statistics.getLocalStats ();
    val user_counters =
      Vector.foldri
        (fn (i, j, res) => ("user_counter" ^ Markup.print_int i, Markup.print_int j) :: res)
        [] userCounters;
  in
    [("full_GCs", Markup.print_int gcFullGCs),
     ("partial_GCs", Markup.print_int gcPartialGCs),
     ("size_allocation", Markup.print_int sizeAllocation),
     ("size_allocation_free", Markup.print_int sizeAllocationFree),
     ("size_heap", Markup.print_int sizeHeap),
     ("size_heap_free_last_full_GC", Markup.print_int sizeHeapFreeLastFullGC),
     ("size_heap_free_last_GC", Markup.print_int sizeHeapFreeLastGC),
     ("threads_in_ML", Markup.print_int threadsInML),
     ("threads_total", Markup.print_int threadsTotal),
     ("threads_wait_condvar", Markup.print_int threadsWaitCondVar),
     ("threads_wait_IO", Markup.print_int threadsWaitIO),
     ("threads_wait_mutex", Markup.print_int threadsWaitMutex),
     ("threads_wait_signal", Markup.print_int threadsWaitSignal),
     ("time_CPU", signed_string_of_real (Time.toReal timeNonGCSystem + Time.toReal timeNonGCUser)),
     ("time_GC", signed_string_of_real (Time.toReal timeGCSystem + Time.toReal timeGCUser))] @
    user_counters
  end;

end;