Re: Help CPU usage at 8.9% ?



Paul, All,
I have a program that calls a data base, retrieves a few data, and based
on that data I would like to generate a few gtklevelhold bars, depending
on the number of data got from the data base. So, the application should
not show any thing upon execution, but rather after a time out has run out
should then create those graphs. Here is what I have done. I have created
a linked list 
typedef struct list{
		char name[6];
		float load;
		struct list *nextptr;
	} ServerData;
I also have another data structure 
struct _Hybrid{
	GtkWidget *table;
	GtkWidget *progressbar;
	int timer;
	ServerData *sd;
} Hybrid;
when my application starts, I create a progress bar and a scrolling window
in which there is vbox init. in the vbox there is table with row=0
column=0. I place a reference to this table in my Hybrid->table. After the
time out
I call a function call
gint update_record(Hybrid *hybrid){

//call data base, get records (no problem here) //
//place them in the link list of Hybrid hybrid->sd //
// call a function update_table //
update_table(Hybrid *hybrid)
which is supposed to create the gtklevelhold bars, update the
hybrid->table by placing bars in the table and display the bars... but it
never happens and I
get a segmentation fault. The bars never appear and my program dies...
with a core dump. Can you help me with what I have done wrong...
-r



On Wed, 15 Nov 2000, Paul Barton-Davis wrote:

> In message <Pine LNX 4 10 10011151819450 2040-100000 localhost localdomain>you 
> write:
> >I have this piece of code that when run, has a 9.0% cpu usage
> 
> Ah, did you mention you were using GtkLevelHold the last time ? :))
> 
> Yes, if you have twenty of these suckers updating every 10msecs,
> you'll be burning a notable fraction of your CPU. The way they use
> GtkRgb (and GdkRgb below it) is not supremely efficient.
> 
> For my project ardour (http://ardour.sourceforge.net), I typically
> have 26 on screen, and its been a growing concern of mine. It would be
> possible to do 90% of the functionality with gdk_copy_area() and 1 or
> 2 pixmaps, but the level *hold* bar is a little tricker to get right.
> 
> So basically, yep, this is exactly what you'd expect.
> 
> However, I would point out that your implementation could be
> improved. You only need a single gtk_timeout_add() - that function can
> itself loop through all _TWTY LevelHolds and update them. This will
> reduce the strain on the main loop scheduling in glib. Right now, you
> have one timeout per bar, which is the wrong way around, IMHO
> 
> --p (seasoned LevelHold user and hacker)
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
> 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]