// We make sure 'doLoadsOfStuff' has a caller, because it is this caller that will be // pushed in the side instrumentation frame. publicvoid ensureCaller(boolean warmup, int invocationCount) throws Exception {
doLoadsOfStuff(warmup, invocationCount);
}
// The number of recursive calls we are going to do in 'doLoadsOfStuff' to ensure // the JIT sees it hot. staticfinalint NUMBER_OF_INVOCATIONS = 5;
publicvoid doLoadsOfStuff(boolean warmup, int invocationCount) throws Exception { // Warmup is to make sure the JIT gets a chance to compile 'doLoadsOfStuff'. if (warmup) { if (invocationCount < NUMBER_OF_INVOCATIONS) {
doLoadsOfStuff(warmup, ++invocationCount);
} else { // Give the JIT a chance to compiler. Thread.sleep(1000);
}
} else { if (invocationCount == 0) { // When running the trace in trace mode, there is already a trace running. if (VMDebug.getMethodTracingMode() != 0) {
VMDebug.stopMethodTracing();
}
VMDebug.startMethodTracing(file.getPath(), 0, 0, false, 0);
}
fillJit(); if (invocationCount < NUMBER_OF_INVOCATIONS) {
doLoadsOfStuff(warmup, ++invocationCount);
} else {
VMDebug.stopMethodTracing();
}
}
}
// This method creates enough profiling data to fill the code cache and trigger // a collection in debug mode (at the time of the test 10KB of data space). We // used to crash by not looking at the instrumentation stack and deleting JIT code // that will be later restored by the instrumentation. publicstaticvoid fillJit() throws Exception {
Map map = new HashMap();
map.put("foo", "bar");
map.clear();
map.containsKey("foo");
map.containsValue("foo");
map.entrySet();
map.equals(map);
map.hashCode();
map.isEmpty();
map.keySet();
map.putAll(map);
map.remove("foo");
map.size();
map.put("bar", "foo");
map.values();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.