Re: gtk_ctree_insert_node - why so slow?
- From: Olaf Frączyk <olaf cbk poznan pl>
- To: John Cupitt <john cupitt ng-london org uk>
- Cc: Olaf Frączyk <olaf cbk poznan pl>, gtk-list gnome org
- Subject: Re: gtk_ctree_insert_node - why so slow?
- Date: Thu, 15 Nov 2001 15:05:40 +0100
On 2001.11.15 13:50:54 +0100 John Cupitt wrote:
Hi Olaf, could you post a test program that shows this bad behaviour?
It'll save us each making one :-)
(maybe you have auto_sort turned on? turn it off, insert 6000 times,
then turn it on again)
Hi,
Of course it's not turned on.
As you wish, I attache a 2 sample programs:
one adds with siblings, other without.
Regards,
Olaf
#include<gtk/gtk.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/timeb.h>
GtkWidget *MainWindow, *MainWindowFixedContainer;
GtkWidget *UsersListCList;
GtkWidget *ScrolledWindowForCList;
struct timeb last_time, current_time;
double olaf_get_time_diff(struct timeb comp_time)
{
struct timeb current_time;
double difference;
ftime(¤t_time);
difference=current_time.millitm - comp_time.millitm;
difference/=1000;
difference+=current_time.time - comp_time.time;
return difference;
}
void ShowList(int num_of_rows)
{
int i;
GtkCTreeNode *node,*parent;
gchar *User[3];
char test[255];
sprintf(test,"I am first of siblings");
User[0]=test;
User[1]=test;
User[2]=NULL;
node=gtk_ctree_insert_node (GTK_CTREE(UsersListCList), NULL, NULL, (char **)User, 2, NULL, NULL, NULL, NULL,FALSE, true);
gtk_clist_freeze(GTK_CLIST(UsersListCList));
for (i=0;i<num_of_rows;i++)
{
sprintf(test,"%i",i);
User[0]=test;
User[1]=test;
User[2]=NULL;
node=gtk_ctree_insert_node (GTK_CTREE(UsersListCList), NULL, node, (char **)User, 2, NULL, NULL, NULL, NULL,FALSE, true);
}
gtk_clist_thaw(GTK_CLIST(UsersListCList));
}
int main(int argc, char *argv[])
{
gtk_init(&argc,&argv);
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(MainWindow),"PPP Control Panel");
gtk_signal_connect(GTK_OBJECT(MainWindow),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
MainWindowFixedContainer=gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(MainWindow),MainWindowFixedContainer);
gtk_widget_show(MainWindowFixedContainer);
gtk_widget_set_usize(MainWindow,390,310);
gtk_window_set_policy(GTK_WINDOW(MainWindow),FALSE,FALSE,FALSE);
ScrolledWindowForCList=gtk_scrolled_window_new(NULL,NULL);
UsersListCList=gtk_ctree_new(2,1);
gtk_container_add(GTK_CONTAINER(ScrolledWindowForCList),UsersListCList);
gtk_fixed_put(GTK_FIXED(MainWindowFixedContainer),ScrolledWindowForCList,5,125);
gtk_widget_set_usize(ScrolledWindowForCList,375,150);
gtk_clist_set_column_title(GTK_CLIST(UsersListCList),0,"Username:");
gtk_clist_set_column_title(GTK_CLIST(UsersListCList),1,"Join time:");
gtk_clist_column_titles_show(GTK_CLIST(UsersListCList));
gtk_clist_column_titles_passive(GTK_CLIST(UsersListCList));
gtk_clist_set_column_width(GTK_CLIST(UsersListCList),0,170);
ftime(&last_time);
printf("Before, %.3f \n",(float)olaf_get_time_diff(last_time));
ShowList(6000);
printf("After, %.3f \n",(float)olaf_get_time_diff(last_time));
gtk_widget_show(UsersListCList);
gtk_widget_show(ScrolledWindowForCList);
gtk_widget_show(MainWindow);
gtk_main();
return(0);
}
#include<gtk/gtk.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/timeb.h>
GtkWidget *MainWindow, *MainWindowFixedContainer;
GtkWidget *UsersListCList;
GtkWidget *ScrolledWindowForCList;
struct timeb last_time, current_time;
double olaf_get_time_diff(struct timeb comp_time)
{
struct timeb current_time;
double difference;
ftime(¤t_time);
difference=current_time.millitm - comp_time.millitm;
difference/=1000;
difference+=current_time.time - comp_time.time;
return difference;
}
void ShowList(int num_of_rows)
{
int i;
GtkCTreeNode *node,*parent;
gchar *User[3];
char test[255];
sprintf(test,"I am first of siblings");
User[0]=test;
User[1]=test;
User[2]=NULL;
node=gtk_ctree_insert_node (GTK_CTREE(UsersListCList), NULL, NULL, (char **)User, 2, NULL, NULL, NULL, NULL,FALSE, true);
gtk_clist_freeze(GTK_CLIST(UsersListCList));
for (i=0;i<num_of_rows;i++)
{
sprintf(test,"%i",i);
User[0]=test;
User[1]=test;
User[2]=NULL;
gtk_ctree_insert_node (GTK_CTREE(UsersListCList), NULL, NULL, (char **)User, 2, NULL, NULL, NULL, NULL,FALSE, true);
}
gtk_clist_thaw(GTK_CLIST(UsersListCList));
}
int main(int argc, char *argv[])
{
gtk_init(&argc,&argv);
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(MainWindow),"PPP Control Panel");
gtk_signal_connect(GTK_OBJECT(MainWindow),"destroy",GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
MainWindowFixedContainer=gtk_fixed_new();
gtk_container_add(GTK_CONTAINER(MainWindow),MainWindowFixedContainer);
gtk_widget_show(MainWindowFixedContainer);
gtk_widget_set_usize(MainWindow,390,310);
gtk_window_set_policy(GTK_WINDOW(MainWindow),FALSE,FALSE,FALSE);
ScrolledWindowForCList=gtk_scrolled_window_new(NULL,NULL);
UsersListCList=gtk_ctree_new(2,1);
gtk_container_add(GTK_CONTAINER(ScrolledWindowForCList),UsersListCList);
gtk_fixed_put(GTK_FIXED(MainWindowFixedContainer),ScrolledWindowForCList,5,125);
gtk_widget_set_usize(ScrolledWindowForCList,375,150);
gtk_clist_set_column_title(GTK_CLIST(UsersListCList),0,"Username:");
gtk_clist_set_column_title(GTK_CLIST(UsersListCList),1,"Join time:");
gtk_clist_column_titles_show(GTK_CLIST(UsersListCList));
gtk_clist_column_titles_passive(GTK_CLIST(UsersListCList));
gtk_clist_set_column_width(GTK_CLIST(UsersListCList),0,170);
ftime(&last_time);
printf("Before, %.3f \n",(float)olaf_get_time_diff(last_time));
ShowList(6000);
printf("After, %.3f \n",(float)olaf_get_time_diff(last_time));
gtk_widget_show(UsersListCList);
gtk_widget_show(ScrolledWindowForCList);
gtk_widget_show(MainWindow);
gtk_main();
return(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]