summaryrefslogtreecommitdiff
path: root/perf/main.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2005-07-26 18:46:01 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2005-07-26 18:46:01 +0000
commit4b4c0fe86c4a12e676a1742adcfaa5b76f590bec (patch)
tree5b906d8c4b0b230be7e58769c98761b14b1ffd5b /perf/main.c
parent98a1367afe28745fcc51c36573aa643344ad42f4 (diff)
downloadgtk+-4b4c0fe86c4a12e676a1742adcfaa5b76f590bec.tar.gz
New directory with the start of a framework for testing performance in
2005-07-26 Federico Mena Quintero <federico@ximian.com> * perf/: New directory with the start of a framework for testing performance in GTK+. * Makefile.am (SRC_SUBDIRS): Added the perf directory. * configure.in (AC_OUTPUT): Generate perf/Makefile.
Diffstat (limited to 'perf/main.c')
-rw-r--r--perf/main.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/perf/main.c b/perf/main.c
new file mode 100644
index 0000000000..cbd8ded174
--- /dev/null
+++ b/perf/main.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include "appwindow.h"
+#include "timers.h"
+
+#define ITERS 20
+
+static GtkWidget *
+create_cb (gpointer data)
+{
+ return appwindow_new ();
+}
+
+static void
+report_cb (TimerReport report, gdouble elapsed, gpointer data)
+{
+ const char *type;
+
+ switch (report) {
+ case TIMER_REPORT_WIDGET_CREATION:
+ type = "widget creation";
+ break;
+
+ case TIMER_REPORT_WIDGET_SHOW:
+ type = "widget show";
+ break;
+
+ case TIMER_REPORT_WIDGET_DESTRUCTION:
+ type = "widget destruction";
+ break;
+
+ default:
+ g_assert_not_reached ();
+ type = NULL;
+ }
+
+ fprintf (stderr, "%s: %g sec\n", type, elapsed);
+
+ if (report == TIMER_REPORT_WIDGET_DESTRUCTION)
+ fputs ("\n", stderr);
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+
+ gtk_init (&argc, &argv);
+
+ for (i = 0; i < ITERS; i++)
+ timer_time_widget (create_cb, report_cb, NULL);
+
+ return 0;
+}