Re: Performance garray/glist



	[I am replying only to gtk-devel-list, which seems the best fit
for this thread...]

On Sun, 25 Mar 2001, Martin Weber wrote:
-> I compared the performance of garray (glib-1.2.8) with STL's vector
-> (STLport-4.1b5) by starting with an array of the length 0 and growing
-> till 10000000 elements. I am using Visual C++ 6.0 and Windows 2000. Here
-> my results:
-> garray: 1928 ms; 99 KB
-> Microsoft STL: 1652 ms; 99 KB
-> STLport-4.1b5: 1350 ms; 99 KB

	Thank you for these stats.  What flags was glib compiled with,
and, can you post the loops that you used?  We'd like to see exactly what
function you used to "grow" the array (set_size()?  append_val()?).


-> Also a wish for new versions. glist is unefficient for certain cases:

	If, by "certain cases", you mean inserting an int directly into
the list, this can already be done in Glib.  See the "G_INT_TO_POINTER"
macro at:

http://developer.gnome.org/doc/API/glib/glib-type-conversion-macros.html

	Basically, your code would read

	for (i = 0; i < n; i++) {
		g_list_append ( list, G_INT_TO_POINTER(i) );
	}


-> for (i = 0; i < n; i++) {
->   g_list_append (glist, i);
-> }

	Also, using g_list_append() is very slow, because Glib does not
retain a pointer to the end of the list (and thus walks the entire list
for every call of g_list_append).  Try your test with g_list_prepend() and
see what kind of results you get :).


Thanks,
Derek Simkowiak
dereks realloc net






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