Skip to content

Commit 35f5d9b

Browse files
committed
Added Truffle::Graal.total_compilation_time
This uses the CompilationMXBean. Signed-off-by: Stefan Marr <[email protected]>
1 parent 4c6e74e commit 35f5d9b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/java/org/truffleruby/extra/TruffleGraalNodes.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import com.oracle.truffle.api.frame.MaterializedFrame;
4242
import com.oracle.truffle.api.nodes.NodeUtil;
4343

44+
import java.lang.management.CompilationMXBean;
45+
import java.lang.management.ManagementFactory;
46+
4447
@CoreModule("Truffle::Graal")
4548
public abstract class TruffleGraalNodes {
4649

@@ -222,4 +225,18 @@ protected Object blackhole(Object value) {
222225

223226
}
224227

228+
@CoreMethod(names = "total_compilation_time", onSingleton = true)
229+
public abstract static class TotalCompilationTimeNode extends CoreMethodArrayArgumentsNode {
230+
private static CompilationMXBean bean;
231+
232+
@TruffleBoundary
233+
@Specialization
234+
protected final long totalCompilationTime() {
235+
if (bean == null) {
236+
bean = ManagementFactory.getCompilationMXBean();
237+
}
238+
239+
return bean.getTotalCompilationTime();
240+
}
241+
}
225242
}

0 commit comments

Comments
 (0)