72250
|
1 |
/* Title: Pure/System/java_statistics.scala
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Java runtime statistics.
|
|
5 |
*/
|
|
6 |
|
|
7 |
package isabelle
|
|
8 |
|
|
9 |
|
75393
|
10 |
object Java_Statistics {
|
72250
|
11 |
/* memory status */
|
|
12 |
|
77708
|
13 |
sealed case class Memory_Status(heap_size: Space, heap_free: Space) {
|
|
14 |
def heap_used: Space = heap_size.used(heap_free)
|
|
15 |
def heap_used_fraction: Double = heap_size.used_fraction(heap_free)
|
72250
|
16 |
}
|
|
17 |
|
75393
|
18 |
def memory_status(): Memory_Status = {
|
77708
|
19 |
val heap_size = Space.bytes(Runtime.getRuntime.totalMemory())
|
|
20 |
val heap_free = Space.bytes(Runtime.getRuntime.freeMemory())
|
73164
|
21 |
Memory_Status(heap_size, heap_free)
|
72250
|
22 |
}
|
|
23 |
|
|
24 |
|
|
25 |
/* JVM statistics */
|
|
26 |
|
75393
|
27 |
def jvm_statistics(): Properties.T = {
|
72250
|
28 |
val status = memory_status()
|
|
29 |
val threads = Thread.activeCount()
|
|
30 |
val workers = Isabelle_Thread.pool.getPoolSize
|
|
31 |
val workers_active = Isabelle_Thread.pool.getActiveCount
|
|
32 |
|
|
33 |
List(
|
|
34 |
"java_heap_size" -> status.heap_size.toString,
|
|
35 |
"java_heap_used" -> status.heap_used.toString,
|
|
36 |
"java_threads_total" -> threads.toString,
|
|
37 |
"java_workers_total" -> workers.toString,
|
|
38 |
"java_workers_active" -> workers_active.toString)
|
|
39 |
}
|
|
40 |
}
|