2003-09-11 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Thu, 11 Sep 2003 12:44:38 +0000 (12:44 -0000)
committerZoltan Varga <vargaz@gmail.com>
Thu, 11 Sep 2003 12:44:38 +0000 (12:44 -0000)
* profiler.c (mono_profiler_load): Added '-time' and '-alloc' options
to the built-in profiler to turn off time and allocation profiling
respectively.

svn path=/trunk/mono/; revision=18033

mono/metadata/ChangeLog
mono/metadata/profiler.c

index ef32b3b6ef961a7ae178dc5d3016296cca8548b1..f3af623d4ad846ac2271b412313bdaccd1e904be 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-11  Zoltan Varga  <vargaz@freemail.hu>
+
+       * profiler.c (mono_profiler_load): Added '-time' and '-alloc' options
+       to the built-in profiler to turn off time and allocation profiling
+       respectively.
+
 2003-09-10  Zoltan Varga  <vargaz@freemail.hu>
 
        * profiler.c (mono_profiler_coverage_alloc): Use NULL instead of
index 95ef185ecbccad0d034a56289b5b1097e74a3803..47162eb3ff4203bb66cca821b4b83050ebf9e406 100644 (file)
@@ -1016,9 +1016,34 @@ static void
 mono_profiler_install_simple (const char *desc)
 {
        MonoProfiler *prof;
+       gchar **args, **ptr;
+       MonoProfileFlags flags = MONO_PROFILE_ENTER_LEAVE|MONO_PROFILE_JIT_COMPILATION|MONO_PROFILE_ALLOCATIONS;
 
        MONO_TIMER_STARTUP;
 
+       if (desc) {
+               /* Parse options */
+               if (strstr (desc, ":"))
+                       desc = strstr (desc, ":") + 1;
+               else
+                       desc = NULL;
+               args = g_strsplit (desc ? desc : "", ",", -1);
+
+               for (ptr = args; ptr && *ptr; ptr++) {
+                       const char *arg = *ptr;
+
+                       if (!strcmp (arg, "-time"))
+                               flags &= ~MONO_PROFILE_ENTER_LEAVE;
+                       else
+                          if (!strcmp (arg, "-alloc"))
+                                  flags &= ~MONO_PROFILE_ALLOCATIONS;
+                          else {
+                                  fprintf (stderr, "profiler : Unknown argument '%s'.\n", arg);
+                                  return;
+                          }
+               }
+       }
+
        prof = create_profiler ();
        prof->tls_id = TlsAlloc ();
        TlsSetValue (prof->tls_id, prof);
@@ -1028,7 +1053,7 @@ mono_profiler_install_simple (const char *desc)
        mono_profiler_install_enter_leave (simple_method_enter, simple_method_leave);
        mono_profiler_install_jit_compile (simple_method_jit, simple_method_end_jit);
        mono_profiler_install_allocation (simple_allocation);
-       mono_profiler_set_events (MONO_PROFILE_ENTER_LEAVE|MONO_PROFILE_JIT_COMPILATION|MONO_PROFILE_ALLOCATIONS);
+       mono_profiler_set_events (flags);
 }
 
 typedef void (*ProfilerInitializer) (const char*);