< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/InitTimer.java

Print this page




  48 
  49     @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field")
  50     public void close() {
  51         final long end = System.currentTimeMillis();
  52         int n = nesting.decrementAndGet();
  53         System.out.println(" DONE: " + SPACES.substring(0, n * 2) + name + " [" + (end - start) + " ms]");
  54         if (n == 0) {
  55             initializingThread = null;
  56         }
  57     }
  58 
  59     public static InitTimer timer(String name) {
  60         return ENABLED ? new InitTimer(name) : null;
  61     }
  62 
  63     public static InitTimer timer(String name, Object suffix) {
  64         return ENABLED ? new InitTimer(name + suffix) : null;
  65     }
  66 
  67     /**
  68      * Specifies if initialization timing is enabled.


  69      */
  70     private static final boolean ENABLED = Boolean.getBoolean("jvmci.inittimer") || Boolean.getBoolean("jvmci.runtime.TimeInit");
  71 
  72     public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null;
  73     public static final String SPACES = "                                            ";
  74 
  75     /**
  76      * Used to assert the invariant that all related initialization happens on the same thread.
  77      */
  78     public static Thread initializingThread;
  79 }


  48 
  49     @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field")
  50     public void close() {
  51         final long end = System.currentTimeMillis();
  52         int n = nesting.decrementAndGet();
  53         System.out.println(" DONE: " + SPACES.substring(0, n * 2) + name + " [" + (end - start) + " ms]");
  54         if (n == 0) {
  55             initializingThread = null;
  56         }
  57     }
  58 
  59     public static InitTimer timer(String name) {
  60         return ENABLED ? new InitTimer(name) : null;
  61     }
  62 
  63     public static InitTimer timer(String name, Object suffix) {
  64         return ENABLED ? new InitTimer(name + suffix) : null;
  65     }
  66 
  67     /**
  68      * Specifies if initialization timing is enabled. Note: this property cannot use
  69      * {@code HotSpotJVMCIRuntime.getBooleanProperty} since that class is not visible from this
  70      * package.
  71      */
  72     private static final boolean ENABLED = Boolean.getBoolean("jvmci.InitTimer");
  73 
  74     public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null;
  75     public static final String SPACES = "                                            ";
  76 
  77     /**
  78      * Used to assert the invariant that all related initialization happens on the same thread.
  79      */
  80     public static Thread initializingThread;
  81 }
< prev index next >