{ return doCall(() -> { StackTraceElement[] stackTrace = new Exception().getStackTrace(); return Class.forName(stackTrace[2].getClassName()); }, stackDepth); } @Benchmark public int stack_depth() throws Exception { return doCall(() -> new Exception().getStackTrace().length, stackDepth); } @Benchmark public Object top_10_frames() throws Exception { return doCall(() -> { StackTraceElement[] stackTrace = new Exception().getStackTrace(); return Arrays.copyOfRange(stackTrace, 0, 10); }, stackDepth); } }