Re: [RFC] Glib::filename_(to|from)_unicode => Glib->filename_(to|from)_unicode?
- From: Torsten Schoenfeld <kaffeetisch web de>
- To: gtk-perl mailing list <gtk-perl-list gnome org>
- Subject: Re: [RFC] Glib::filename_(to|from)_unicode => Glib->filename_(to|from)_unicode?
- Date: Wed, 24 Dec 2003 15:11:36 +0100
On Wed, 2003-12-24 at 10:17, A. Pagaltzis wrote:
string = Glib->filename_to_unicode(string)
string = Glib->filename_from_unicode(string)
At the same time, that syntax forces Perl to do more work to find the
function to call and pass the class name to the function.
I implemented the arrow using XS subs[0] and according to my
benchmark[1] the colon syntax is only about 13% faster[2], which is
negligible.
Bye,
-Torsten
[0]
const char *
filename_from_unicode_with_class (class, filename)
GPerlFilename filename
CODE:
RETVAL = filename;
OUTPUT:
RETVAL
GPerlFilename_const
filename_to_unicode_with_class (class, filename)
const char *filename
CODE:
RETVAL = filename;
OUTPUT:
RETVAL
[1]
#!/usr/bin/perl -w
use strict;
use Glib;
use Benchmark;
my $coloncolon = sub {
my $unicode = Glib::filename_to_unicode("bla");
my $filename = Glib::filename_from_unicode($unicode);
};
my $arrow = sub {
my $unicode = Glib -> filename_to_unicode_with_class("bla");
my $filename = Glib -> filename_from_unicode_with_class($unicode);
};
timethese(1_000_000, {
coloncolon => $coloncolon,
arrow => $arrow
});
[2]
Benchmark: timing 1000000 iterations of arrow, coloncolon...
arrow: 13 wallclock secs (13.78 usr + 0.22 sys = 14.00 CPU) @
71428.57/s (n=1000000)
coloncolon: 13 wallclock secs (12.22 usr + 0.18 sys = 12.40 CPU) @
80645.16/s (n=1000000)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]