Re: Size of GtkPerl (compared to PyGtk)



On 04/24/01 dLux wrote:
I  have found  that the  Gtk.so  is about  800-900K, and  the size  of
PyGtk  is  about  400-500K.  Anyone, who  knows  both  interfaces  can
answer why this difference occurs in the glue-size?

PyGtk wraps only a subset of the capabilities of the Gtk+ library
and the perl binding may require a bit more binary size per
function wrapped.
Anyway, if you want some real numbers to compare the perl and python
bindings for resource usage this may help (you can find the complete
thread in the gnome-hackers archive):

Loading speed in ms (on my K6 400 with 128 MB RAM):
The python program are 'from gtk import *' and 'from gnome.ui import *'.
The perl programs are 'perl -MGtk=-init -e 0' and 
'perl -MGnome -e "init Gnome $0"'.

        python  perl
gtk     0.715   0.680   (took the best result for python and the worse for
                        perl in a number of runs each after a find /)
gtk
cached  0.715   0.280  (values taken after running the same program a few 
                        times, best value for python, worst for perl: the
                        average for perl is about 0.230)
gnome   1.083   0.777   (same as above for the Gnome support)
gnome
cached  1.085   0.379

So, the perl binding loads 3 times faster when there is an already running
interpreter. It would be interesting to have the numbers for smaller
machines, though.
I'd like to have the numbers for other scripting langages bindings, too.
FYI, for C programs I get 0.105 (gtk) and 0.230 (gnome).

Memory requirements: I used the same programs as above running under
memprof (after adding a sleep() call at the end) and noting the max 
memory usage. Please point out if there are better ways to do this
or if the results from this procedure are not significant for some 
reason.

        python  perl
gtk     1032 KB 915 KB
gnome   1576 KB 1341 KB

I have already implemented a lazy-loading mechanism in cvs gnome-perl
that reduces the perl numbers to 710 KB and 1031 KB (if the
program uses _all_ the widgets in gtk and gnome there is no change
in the end, but this is unlikely).

Completeness: it's really hard to find a way to measure this, but let's
try anyway, since the results I get seem to imply the perl binding is the
more complete:-) The program I used is attached. It works this way:
for a number of libraries (libgtk, libgdk, libgnome etc. in the gnome
core) it checks the exported symbols and matches them against the
symbols required by the langauge bindings dynamic modules. I used to
use the program to find what functions are missing in my binding, but I
added a check for the python and guile modules while I was at it:-)
Note that some of the missing functions are bogus or useless for
a binding implementation. I think I have an almost complete perl,
python and guile gnome devel environment: let me know what numbers you
get (it's possible I'm missing some module or maybe the guile binding
doesn't have symbol references for all the functions it supports?).

Missing funcs in perl binding: 972/3201 total
Missing funcs in python binding: 1479/3201 total
Missing funcs in guile binding: 2220/3201 total

Executive summary:
Perl and python use basically the same disk space.
The perl binding loads faster, uses less memory and is more complete.

lupus

-- 
-----------------------------------------------------------------
lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better

--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=makebinded

#!/usr/bin/perl -w

@libs = qw(
        libgdk-1.2.so.0 libgtk-1.2.so.0 libgnomeui.so.32 libzvt.so.2 
        libpanel_applet.so.0 libgdk_pixbuf.so.2 libgnomeprint.so.11
        libgnome.so.32 libgdk_imlib.so.1 libgtkhtml.so.7 libgtkxmhtml.so.1
);

$lang = shift || 'perl';

if ($lang eq 'perl') {
        @modules = `find . -name \*.so`;
} elsif ($lang eq 'python') {
        @modules = glob("/usr/lib/python1.5/site-packages/*.so");
} elsif ($lang eq 'guile') {
        @modules = glob("/usr/lib/libguile*.so.0");
}

@nobind{qw(gtk_input_add_full gtk_input_remove)} = ();
foreach (qw(set setv get getv newv)) {
        $nobind{"gtk_widget_".$_} = 1;
}

%funcs = ();
$ident = '[_a-zA-Z][_a-zA-Z0-9]*';

for $i (@libs) {
        $i = "/usr/lib/$i" unless -f $i;
        open(N, "nm -D $i|") || die "Cannot open pipe: $!\n";
        while(<N>) {
                next unless / T ($ident)/o;
                $f = $1;
                next if $f =~ m/^(_|g_|gt1_|Xm|html_|gp_|gtk_marshal_|GNOME_|_ORBIT|POA_|vt_|CORBA_)/;
                $funcs{$f} = 1 unless exists $nobind{$f};
        }
        close(N);
}
$total = scalar(keys %funcs);
foreach $i (@modules) {
        open(N, "nm -D $i|") || die "Cannot open pipe: $!\n";
        while(<N>) {
                next unless / U ($ident)/o;
                delete $funcs{$1};
        }
        close(N);
}

print "Missing funcs in $lang binding: ", scalar(keys %funcs), "/$total total\n";
#print join("\n", sort keys %funcs), "\n";


--tThc/1wpZn/ma/RB--

-- 
-----------------------------------------------------------------
lupus debian org                                     debian/rules
lupus ximian com                             Monkeys do it better




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