clist preformance
- From: Ralf Forsberg <rfg home se>
- To: gtk-devel-list redhat com
- Subject: clist preformance
- Date: Wed, 8 Mar 2000 22:19:11 +0100
Hello,
The following program give g_list_nth() quite a
workout , it uses 99.95% cpu time for me and
finishes in just under one minute (pentium233).
It is faster if I set the text directly when adding
the rows, but I don't want to do that.
-----------------------
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h>
#define NR_ROWS 20000
int main(int argc, char *argv[])
{
char *column_titles[]=
{
"1","2","3"
};
int err;
int i,j;
GtkWidget *window;
GtkWidget *scrolled_win;
GtkWidget *clist;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window),600,500);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show(scrolled_win);
clist = gtk_clist_new_with_titles (3, column_titles);
gtk_widget_show(clist);
gtk_clist_set_column_width (GTK_CLIST (clist), 0, 80);
gtk_clist_set_column_width (GTK_CLIST (clist), 1, 80);
gtk_clist_set_column_width (GTK_CLIST (clist), 2, 80);
gtk_container_add (GTK_CONTAINER (scrolled_win), clist);
gtk_container_add(GTK_CONTAINER(window),scrolled_win);
gtk_widget_show(clist);
gtk_widget_show(scrolled_win);
gtk_widget_show_now(window);
gtk_clist_freeze(GTK_CLIST(clist));
for(i=0;i<NR_ROWS;i++)
{
gtk_clist_append(GTK_CLIST(clist),column_titles);
}
for(i=0;i<NR_ROWS;i++)
{
for(j=0;j<3;j++)
{
gtk_clist_set_text(GTK_CLIST(clist),
i,j,"test");
}
}
gtk_clist_thaw(GTK_CLIST(clist));
gtk_main();
return 0;
}
-----------------------
/ Ralf
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]