diff --git a/base/timing.jl b/base/timing.jl index ab7af23048305..8ddee831c07f0 100644 --- a/base/timing.jl +++ b/base/timing.jl @@ -58,6 +58,8 @@ end # cumulative total time spent on compilation cumulative_compile_time_ns_before() = ccall(:jl_cumulative_compile_time_ns_before, UInt64, ()) cumulative_compile_time_ns_after() = ccall(:jl_cumulative_compile_time_ns_after, UInt64, ()) +# cumulative total time this thread has spent on compilation since process start. +cumulative_compile_time_ns() = ccall(:jl_cumulative_compile_time_ns, UInt64, ()) # total time spend in garbage collection, in nanoseconds gc_time_ns() = ccall(:jl_gc_total_hrtime, UInt64, ()) diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp index f13a1af3352fd..0e3bf4035d831 100644 --- a/src/jitlayers.cpp +++ b/src/jitlayers.cpp @@ -90,6 +90,12 @@ uint64_t jl_cumulative_compile_time_ns_after() return jl_cumulative_compile_time[tid]; } +extern "C" JL_DLLEXPORT +uint64_t jl_cumulative_compile_time_ns() { + int tid = jl_threadid(); + return jl_cumulative_compile_time[tid]; +} + // this generates llvm code for the lambda info // and adds the result to the jitlayers // (and the shadow module), diff --git a/test/misc.jl b/test/misc.jl index e765dc9279b86..7d38b4622a024 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -263,6 +263,19 @@ function timev_macro_scope() end @test timev_macro_scope() == 1 + +t1 = @async @time begin + sleep(2) + @eval module M ; f(x,y) = x+y ; end + @eval M.f(2,3) +end + +t2 = @async begin + sleep(1) + @time 2 + 2 +end + + # interactive utilities struct ambigconvert; end # inject a problematic `convert` method to ensure it still works