Esempio n. 1
0
static void
print_exit_report (void)
{
  if (!(clutter_profile_flags & CLUTTER_PROFILE_DISABLE_REPORT))
    uprof_report_print (clutter_uprof_report);

  uprof_report_unref (clutter_uprof_report);

  uprof_context_unref (_clutter_uprof_context);
}
Esempio n. 2
0
void
uprof_context_unlink (UProfContext *context, UProfContext *other)
{
  GList *l = g_list_find (context->links, other);
  if (l)
    {
      uprof_context_unref (other);
      context->links = g_list_delete_link (context->links, l);
      _uprof_context_dirty_resolved_state (context);
    }
}
Esempio n. 3
0
clutter_uprof_destructor (void)
{
  if (!(clutter_profile_flags & CLUTTER_PROFILE_DISABLE_REPORT))
    {
      UProfReport *report = uprof_report_new ("Clutter report");
      uprof_report_add_context (report, _clutter_uprof_context);
      uprof_report_add_context_callback (report, print_report);
      uprof_report_print (report);
      uprof_report_unref (report);
    }
  uprof_context_unref (_clutter_uprof_context);
}
Esempio n. 4
0
int
main (int argc, char **argv)
{
  UProfReport *report;
  UProfContext *context;
  int i;

  uprof_init (&argc, &argv);

  context = uprof_context_new ("Test");


  for (i = 0; i < 4; i ++)
    {
      struct timespec delay;

      if (i == 1)
        {
          DBG_PRINTF ("suspending context\n");
          uprof_context_suspend (context);
        }

      UPROF_COUNTER_INC (context, loop_counter);

      UPROF_TIMER_START (context, loop_timer);
      DBG_PRINTF ("  <delay: 1 sec>\n");
      delay.tv_sec = 1;
      delay.tv_nsec = 0;
      nanosleep (&delay, NULL);

      UPROF_TIMER_STOP (context, loop_timer);
      DBG_PRINTF ("stop simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
                  uprof_get_system_counter ());

      if (i == 2)
        {
          DBG_PRINTF ("resuming context\n");
          uprof_context_resume (context);
        }
    }

  DBG_PRINTF ("Expected result = 2 seconds accounted for and count == 2:\n");

  report = uprof_report_new ("Suspend report");
  uprof_report_add_context (report, context);
  uprof_report_print (report);
  uprof_report_unref (report);

  uprof_context_unref (context);

  return 0;
}
Esempio n. 5
0
void
uprof_context_unref (UProfContext *context)
{
  context->ref--;
  if (!context->ref)
    {
      GList *l;
      g_free (context->name);

      for (l = context->counters; l != NULL; l = l->next)
        {
          _uprof_object_state_dispose (l->data);
          g_slice_free (UProfCounterState, l->data);
        }
      g_list_free (context->counters);

      for (l = context->timers; l != NULL; l = l->next)
        {
          UProfTimerState *timer = l->data;
          _uprof_object_state_dispose (l->data);
          if (timer->parent && timer->parent_name)
            g_free (timer->parent_name);
          g_slice_free (UProfTimerState, l->data);
        }
      g_list_free (context->timers);

      for (l = context->report_messages; l != NULL; l = l->next)
        g_free (l->data);
      g_list_free (context->report_messages);

      for (l = context->links; l != NULL; l = l->next)
        uprof_context_unref (l->data);
      g_list_free (context->links);

      _uprof_context_free_options (context);

      _uprof_all_contexts = g_list_remove (_uprof_all_contexts, context);
      g_free (context);
    }
}
Esempio n. 6
0
int
main (int argc, char **argv)
{
  UProfContext *context;
  UProfReport *report;
  int i;

  uprof_init (&argc, &argv);

  context = uprof_context_new ("Simple context");


  DBG_PRINTF ("start full timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
              uprof_get_system_counter ());
  UPROF_TIMER_START (context, full_timer);
  for (i = 0; i < 2; i ++)
    {
      struct timespec delay;
      UPROF_COUNTER_INC (context, loop0_counter);

      DBG_PRINTF ("start simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
                  uprof_get_system_counter ());
      UPROF_TIMER_START (context, loop0_timer);
      DBG_PRINTF ("  <delay: 1/2 sec>\n");
      delay.tv_sec = 0;
      delay.tv_nsec = 1000000000/2;
      nanosleep (&delay, NULL);

      UPROF_TIMER_START (context, loop0_sub_timer);
      DBG_PRINTF ("    <timing sub delay: 1/4 sec>\n");
      delay.tv_sec = 0;
      delay.tv_nsec = 1000000000/4;
      nanosleep (&delay, NULL);
      UPROF_TIMER_STOP (context, loop0_sub_timer);

      UPROF_TIMER_STOP (context, loop0_timer);
      DBG_PRINTF ("stop simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
                  uprof_get_system_counter ());
    }

  for (i = 0; i < 4; i ++)
    {
      struct timespec delay;
      UPROF_COUNTER_INC (context, loop1_counter);

      DBG_PRINTF ("start simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
                  uprof_get_system_counter ());
      UPROF_TIMER_START (context, loop1_timer);
      DBG_PRINTF ("  <delay: 1/4 sec>\n");
      delay.tv_sec = 0;
      delay.tv_nsec = 1000000000/4;
      nanosleep (&delay, NULL);

      UPROF_TIMER_START (context, loop1_sub_timer);
      DBG_PRINTF ("    <timing sub delay: 1/2 sec>\n");
      delay.tv_sec = 0;
      delay.tv_nsec = 1000000000/2;
      nanosleep (&delay, NULL);
      UPROF_TIMER_STOP (context, loop1_sub_timer);

      UPROF_TIMER_STOP (context, loop1_timer);
      DBG_PRINTF ("stop simple timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
                  uprof_get_system_counter ());
    }

  DBG_PRINTF ("stop full timer (rdtsc = %" G_GUINT64_FORMAT ")\n",
              uprof_get_system_counter ());
  UPROF_TIMER_STOP (context, full_timer);

  report = uprof_report_new ("Simple report");
  uprof_report_add_statistic (report,
                              "Special thingy",
                              "This is a particularly interesting thingy");
  uprof_report_add_statistic_attribute (report,
                                        "Special thingy",
                                        "Thingy A value",
                                        "Thingy A\nvalue",
                                        "The real A value of thingys",
                                        UPROF_ATTRIBUTE_TYPE_WORD,
                                        a_values_cb, NULL);
  uprof_report_add_statistic_attribute (report,
                                        "Special thingy",
                                        "Thingy B value",
                                        "Thingy B\nvalue",
                                        "The real B value of thingys",
                                        UPROF_ATTRIBUTE_TYPE_WORD,
                                        b_values_cb, NULL);

  uprof_report_add_statistic (report,
                              "Special dobble",
                              "This is a particularly interesting dobble");
  uprof_report_add_statistic_attribute (report,
                                        "Special dobble",
                                        "Dobble value",
                                        "Dobble\nvalue",
                                        "The real value of dobbles",
                                        UPROF_ATTRIBUTE_TYPE_FLOAT,
                                        dobbles_cb, NULL);

  uprof_report_add_timers_attribute (report,
                                     "Time in seconds",
                                     "Time in\nseconds",
                                     "The time elapsed in seconds",
                                     UPROF_ATTRIBUTE_TYPE_INT,
                                     seconds_column_cb, NULL);
  uprof_report_add_counters_attribute (report,
                                       "Double count",
                                       "Double\ncount",
                                       "The count doubled",
                                       UPROF_ATTRIBUTE_TYPE_INT,
                                       double_count_cb, NULL);
  uprof_report_add_counters_attribute (report,
                                       "Tripple count",
                                       "Tripple\ncount",
                                       "The count trippled",
                                       UPROF_ATTRIBUTE_TYPE_INT,
                                       tripple_count_cb, NULL);

  uprof_report_add_context (report, context);
  uprof_report_print (report);
  uprof_report_unref (report);

  uprof_context_unref (context);

  return 0;
}