Beispiel #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);
}
Beispiel #2
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);
}
Beispiel #3
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;
}
Beispiel #4
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;
}