To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

stat.scala 1.46 KB
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1
2
3
4
5
6
7
8
9
package uvm.refimpl

import scala.collection.mutable.HashMap
import uvm.ssavariables.Instruction

class VMStats {
  var exceptionsThrown: Long = 0L
  var peiCalled: Long = 0L
  var allocaExecuted: Long = 0L
Kunshan Wang's avatar
Kunshan Wang committed
10
11
12
  var bytesAllocatedHeap: Long = 0L

  val heapAllocSizeMap: HashMap[Long, Long] = new HashMap()
Kunshan Wang's avatar
Kunshan Wang committed
13
14
15
16
17
18
19
20
  val instExecCount: HashMap[String, Long] = new HashMap()
  
  def onInstExec(i: String): Unit = {
    val oldCount = instExecCount.getOrElse(i, 0L)
    val newCount = oldCount + 1
    instExecCount.update(i, newCount)
  }
  
Kunshan Wang's avatar
Kunshan Wang committed
21
22
23
24
25
26
27
28
  def onHeapAlloc(sz: Long): Unit = {
    bytesAllocatedHeap += sz
    
    val oldCount = heapAllocSizeMap.getOrElse(sz, 0L)
    val newCount = oldCount + 1
    heapAllocSizeMap.update(sz, newCount)
  }
  
Kunshan Wang's avatar
Kunshan Wang committed
29
30
31
32
33
34
35
36
37
38
39
  def getStatesString(): String = {
    val sb = new StringBuilder()
    sb ++= "Exceptions thrown: %d\n".format(exceptionsThrown)
    sb ++= "PEI called: %d\n".format(peiCalled)
    sb ++= "ALLOCA and ALLOCAHYBRID executed: %d\n".format(peiCalled)
    
    sb ++= "Instructions executed:\n"
    for ((i, c) <- instExecCount.toSeq.sortBy(_._2).reverse) {
      sb ++= "  %s: %d\n".format(i, c)
    }
    
Kunshan Wang's avatar
Kunshan Wang committed
40
41
42
43
44
45
    sb ++= "Bytes allocated on the heap (only small obj space): %d\n".format(bytesAllocatedHeap)
    sb ++= "Heap object size : allocation count:\n"
    for ((i, c) <- heapAllocSizeMap.toSeq.sortBy(_._1)) {
      sb ++= "  %d: %d\n".format(i, c)
    }
    
Kunshan Wang's avatar
Kunshan Wang committed
46
47
48
49
50
51
52
53
54
    sb.toString()
  }
  
  def printState(): Unit = {
    print(getStatesString())
  }
  
  
}