2005-07-26 18:46:01 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <gtk/gtk.h>
|
2005-07-29 00:38:51 +00:00
|
|
|
#include "gtkwidgetprofiler.h"
|
|
|
|
#include "widgets.h"
|
2005-07-26 18:46:01 +00:00
|
|
|
|
2005-07-29 00:38:51 +00:00
|
|
|
#define ITERS 10
|
2005-07-26 18:46:01 +00:00
|
|
|
|
|
|
|
static GtkWidget *
|
2005-07-29 00:38:51 +00:00
|
|
|
create_widget_cb (GtkWidgetProfiler *profiler, gpointer data)
|
2005-07-26 18:46:01 +00:00
|
|
|
{
|
|
|
|
return appwindow_new ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-07-29 00:38:51 +00:00
|
|
|
report_cb (GtkWidgetProfiler *profiler, GtkWidgetProfilerReport report, GtkWidget *widget, gdouble elapsed, gpointer data)
|
2005-07-26 18:46:01 +00:00
|
|
|
{
|
|
|
|
const char *type;
|
|
|
|
|
|
|
|
switch (report) {
|
2005-07-29 00:38:51 +00:00
|
|
|
case GTK_WIDGET_PROFILER_REPORT_CREATE:
|
2005-07-26 18:46:01 +00:00
|
|
|
type = "widget creation";
|
|
|
|
break;
|
|
|
|
|
2005-07-29 00:38:51 +00:00
|
|
|
case GTK_WIDGET_PROFILER_REPORT_MAP:
|
|
|
|
type = "widget map";
|
2005-07-26 18:46:01 +00:00
|
|
|
break;
|
|
|
|
|
2005-07-29 00:38:51 +00:00
|
|
|
case GTK_WIDGET_PROFILER_REPORT_EXPOSE:
|
|
|
|
type = "widget expose";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_WIDGET_PROFILER_REPORT_DESTROY:
|
2005-07-26 18:46:01 +00:00
|
|
|
type = "widget destruction";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
type = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf (stderr, "%s: %g sec\n", type, elapsed);
|
|
|
|
|
2005-07-29 00:38:51 +00:00
|
|
|
if (report == GTK_WIDGET_PROFILER_REPORT_DESTROY)
|
2005-07-26 18:46:01 +00:00
|
|
|
fputs ("\n", stderr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2005-07-29 00:38:51 +00:00
|
|
|
GtkWidgetProfiler *profiler;
|
2005-07-26 18:46:01 +00:00
|
|
|
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
2005-07-29 00:38:51 +00:00
|
|
|
profiler = gtk_widget_profiler_new ();
|
|
|
|
g_signal_connect (profiler, "create-widget",
|
|
|
|
G_CALLBACK (create_widget_cb), NULL);
|
|
|
|
g_signal_connect (profiler, "report",
|
|
|
|
G_CALLBACK (report_cb), NULL);
|
|
|
|
|
|
|
|
gtk_widget_profiler_set_num_iterations (profiler, ITERS);
|
|
|
|
gtk_widget_profiler_profile_boot (profiler);
|
2005-07-26 18:46:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|