Include JIT time in --stats output.
authorZoltan Varga <vargaz@gmail.com>
Mon, 1 Nov 2010 22:53:10 +0000 (23:53 +0100)
committerZoltan Varga <vargaz@gmail.com>
Mon, 1 Nov 2010 23:27:54 +0000 (00:27 +0100)
mono/mini/mini.c
mono/mini/mini.h

index 76475e270ea8f2c6b61e1c8c2f9e88b145251833..24b66e7511b392c4d3f0df098d9978ba5e50283f 100644 (file)
@@ -3859,7 +3859,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
                mono_profiler_method_jit (method);
        if (MONO_PROBE_METHOD_COMPILE_BEGIN_ENABLED ())
                MONO_PROBE_METHOD_COMPILE_BEGIN (method);
+
        if (compile_aot)
                /* 
                 * We might get passed the original generic method definition or
@@ -4742,6 +4742,7 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
        MonoVTable *vtable;
        MonoException *ex = NULL;
        guint32 prof_options;
+       GTimer *jit_timer;
 
 #ifdef MONO_USE_AOT_COMPILER
        if (opt & MONO_OPT_AOT) {
@@ -4836,8 +4837,14 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                return NULL;
        }
 
+       jit_timer = g_timer_new ();
+
        cfg = mini_method_compile (method, opt, target_domain, TRUE, FALSE, 0);
 
+       g_timer_stop (jit_timer);
+       mono_jit_stats.jit_time += g_timer_elapsed (jit_timer, NULL);
+       g_timer_destroy (jit_timer);
+
        switch (cfg->exception_type) {
        case MONO_EXCEPTION_NONE:
                break;
@@ -5720,6 +5727,7 @@ register_jit_stats (void)
        mono_counters_register ("Methods from AOT", MONO_COUNTER_JIT | MONO_COUNTER_WORD, &mono_jit_stats.methods_aot);
        mono_counters_register ("Methods JITted using LLVM", MONO_COUNTER_JIT | MONO_COUNTER_INT, &mono_jit_stats.methods_with_llvm);   
        mono_counters_register ("Methods JITted using mono JIT", MONO_COUNTER_JIT | MONO_COUNTER_INT, &mono_jit_stats.methods_without_llvm);
+       mono_counters_register ("Total time spent JITting (sec)", MONO_COUNTER_JIT | MONO_COUNTER_DOUBLE, &mono_jit_stats.jit_time);
 }
 
 static void runtime_invoke_info_free (gpointer value);
index 6b7f50f8a3ed248fe1219e856222016d78bedad9..204b47df4c600e08daf7eb4f0af99dfb21265c4a 100644 (file)
@@ -1250,6 +1250,7 @@ typedef struct {
        int methods_without_llvm;
        char *max_ratio_method;
        char *biggest_method;
+       double jit_time;
        gboolean enabled;
 } MonoJitStats;