Re: decrease widget show time
- From: Tomeu Vizoso <tomeu sugarlabs org>
- To: czk <czongke gmail com>
- Cc: gtk-devel-list gnome org, Markku Vire <markku vire iki fi>
- Subject: Re: decrease widget show time
- Date: Fri, 25 Mar 2011 11:10:57 +0100
2011/3/21 czk <czongke gmail com>:
> Following is my test program and test result:
As someone else said on this thread, most of the time is likely going
into some lazy initializations and not on showing widgets.
If you are going to do any work that may require looking at
performance issues then you are going to need good tools to do the
job. As a first step, I recommend you to get sysprof running. Report
the results here if you need help interpreting them.
Regards,
Tomeu
> --------------------------------------------------------
> #include <gtk/gtk.h>
>
> static const char *text[] = {
> "hello, world",
> "nihao entry",
> "Slide and release",
> "the power switch to wake",
> "become impassioned or",
> "excited: the young man"
> };
>
> static void
> button_clicked (GtkWidget *widget, gpointer data)
> {
> g_print ("button %p clicked, data=%d\n", widget, (gint)data);
> }
>
> int main (int argc, char *argv[])
> {
> GtkWidget *window;
> GtkWidget *vbox;
> GtkWidget *button;
> int i;
> gint64 t[20];
> gint cnt = 0;
>
> gtk_init (&argc, &argv);
>
> t[cnt++] = g_get_monotonic_time ();
> gtk_settings_get_for_screen (gdk_screen_get_default ());
> t[cnt++] = g_get_monotonic_time ();
> window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> gtk_widget_set_size_request (window, 300, 400);
> t[cnt++] = g_get_monotonic_time ();
> vbox = gtk_vbox_new (FALSE, 5);
> gtk_widget_show (vbox);
> t[cnt++] = g_get_monotonic_time ();
> for (i = 0; i < 5; i++)
> {
> button = gtk_button_new_with_label (text[i]);
> gtk_widget_show (button);
>
> g_signal_connect (button, "clicked", G_CALLBACK (button_clicked),
> (gpointer)i);
>
> gtk_box_pack_start (GTK_BOX(vbox), button, TRUE, FALSE, 5);
> }
>
> gtk_container_add (GTK_CONTAINER (window), vbox);
> gtk_container_set_border_width (GTK_CONTAINER (window), 10);
>
> t[cnt++] = g_get_monotonic_time ();
> gtk_widget_show (window);
> t[cnt++] = g_get_monotonic_time ();
>
> gdk_window_process_updates (gtk_widget_get_window (window), TRUE);
> t[cnt++] = g_get_monotonic_time ();
>
> g_print("time(cnt=%d)(start=%lld): ", cnt, t[0]/1000);
> for (i = 1; i < cnt; i++)
> g_print("[%d]=%lld ", i, (t[i] - t[i-1])/1000);
> g_print("total=%lld (end=%lld)\n", (t[i-1] - t[0])/1000, t[i-1]/1000);
>
> gtk_main ();
>
> return 0;
> }
> -------------------------------
> the result is:
> time(cnt=7)(start=5830680): [1]=210 [2]=110 [3]=10 [4]=140 [5]=1430 [6]=270
> total=2170 (end=5832850)
>
> cat /proc/cupinfo
> Processor : ARMv6-compatible processor rev 7 (v6l)
> BogoMIPS : 323.58
> Features : swp half thumb fastmult vfp edsp java
> CPU implementer : 0x41
> CPU architecture: 7
> CPU variant : 0x0
> CPU part : 0xb76
> CPU revision : 7
> Hardware : Reference Board for TV/STB SoC
> Revision : 0000
> Serial : 0000000000000000
> ===================================
> Obviously, most time spend on the last gtk_widget_show.
>
> 2011/3/20 Markku Vire <markku vire iki fi>
>>
>> Hi,
>>
>> On Fri, 2011-03-18 at 14:13 +0800, czk wrote:
>> > hello everyone,
>> > I use gtk+-3.0 in a embedded device. If I create a window put 4
>> > buttons , 4 entrys 3 labels in it, from gtk_window_new to the window
>> > was showed spend 4 seconds totally. It a long time for me. Most time
>> > spend in gtk_widget_show_all.
>> >
>> > Less than 1.5 second can acceptable. Any one has ideas? Thanks.
>>
>> Sounds like you're searching the reason from a wrong place. The core Gtk
>> functions like gtk_widget_show_all consume practically no time by
>> themselves (even on embedded device). It's far more likely that you
>> encounter some hidden "lazy" initialization. For example, on Gtk+2.0 the
>> theme parsing and realization took place when you first time tried to
>> show a toplevel.
>>
>> cheers,
>>
>> -Markku-
>>
>>
>
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]