summaryrefslogtreecommitdiff
path: root/perf/main.c
blob: cbd8ded174ee8df59e06dff9017206e6d4838736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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;
}