< 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.Option} since that class is not visible from this package.
  70      */
  71     private static final boolean ENABLED = Boolean.getBoolean("jvmci.InitTimer");
  72 
  73     public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null;
  74     public static final String SPACES = "                                            ";
  75 
  76     /**
  77      * Used to assert the invariant that all related initialization happens on the same thread.
  78      */
  79     public static Thread initializingThread;
  80 }
< prev index next >