The System>>#totalCompilationTime primitive does currently only report C1 & C2 compilation time as reported by Hotspot.
One way of fixing this might be to use the Truffle-related JFR events: https://github.com/oracle/graal/tree/master/truffle/src/com.oracle.truffle.runtime/src/com/oracle/truffle/runtime/jfr
Using EventStream.openRepository() it should be possible to get those inside the process and report them: https://docs.oracle.com/en/java/javase/24/docs/api/jdk.jfr/jdk/jfr/consumer/EventStream.html
For native-image, it might require extra flags: https://www.graalvm.org/22.0/reference-manual/native-image/JFR/
Not sure what the situation of HotSpot is.